From 19c66ba052a7fb26c4d27deaa75ae46479eee342 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 01 四月 2024 10:36:44 +0800
Subject: [PATCH] 优化堆垛逻辑和入库逻辑

---
 代码管理/PCS/WCS_Client/src/extension/widesea_system/system/dt_log_pcs.js                           |    7 
 代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/VV_Mes_WorkinfoController.cs         |   21 
 代码管理/PCS/WCS_Server/WIDESEA_Comm/LogInfo/WriteDBLog.cs                                          |   15 
 代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs                |   21 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs                                  |  120 ++
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs                                                |  327 +++++---
 代码管理/PCS/WCS_Server/WIDESEA_WebApi/Controllers/ToMes/ToMESController.cs                         |    4 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/ToMes/agvTransferList.cs                                        |   65 +
 代码管理/WMS/WMS_Server/WIDESEA_WMS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs               |   18 
 项目资料/其他/服务器账号密码.txt                                                                             |    3 
 代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs                          |   21 
 代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_stationinfo.cs                        |    2 
 代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs                        |  164 ++++
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs                                        |    3 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs                |   41 +
 代码管理/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs                                 |   18 
 代码管理/WMS/WMS_Client/src/api/http.js                                                             |    2 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask_Mes.cs                                |   58 +
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs                 |   24 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/EmptyTrayTask.cs                                |   58 +
 代码管理/WMS/WMS_Server/WIDESEA_WMS/ToAGV/ToAGVServer.cs                                            |    6 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data.vue                         |    2 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data_detectionline.vue           |    2 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/VV_Mes_WorkinfoService.cs                        |   27 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs                                     |    4 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail_hty.vue                           |   10 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs              |   13 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head_hty.vue                             |   17 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs                               |    8 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head.vue                                 |   16 
 代码管理/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask_hty.vue                      |    2 
 代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs                          |    4 
 代码管理/WMS/WMS_Server/WIDESEA_Entity/MappingConfiguration/ToMES/VV_Mes_WorkinfoMapConfig.cs       |   16 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/ToAGV/ToAGVServer.cs                                            |    2 
 代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs                |   21 
 代码管理/WMS/WMS_Client/src/views/widesea_wms/system/dt_inventory.vue                               |   15 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/OutboundTask_a.cs                          |    2 
 代码管理/PCS/WCS_Client/src/api/http.js                                                             |    2 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs                    |   28 
 代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs                          |    6 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs                                   |   66 +
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs                |   41 +
 代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs                          |   10 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs                  |    6 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/VV_Mes_WorkinfoService.cs                        |   27 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/IVV_Mes_WorkinfoService.cs                      |   12 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs               |   18 
 代码管理/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail.vue                               |    2 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs                                   |   29 
 代码管理/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js                              |   39 +
 代码管理/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask.vue                          |    2 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs                                    |   28 
 代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/Partial/VV_Mes_WorkinfoController.cs |   33 
 代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs                        |  164 ++++
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs                 |   24 
 代码管理/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs     |   14 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/IVV_Mes_WorkinfoService.cs                      |   12 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/GetLocation.cs                             |  271 +++++++
 代码管理/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs              |   13 
 代码管理/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue                             |    8 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs                                       |   47 
 代码管理/PCS/WCS_Client/config/buttons.js                                                           |    9 
 代码管理/PCS/WCS_Client/src/views/system/Sys_User.vue                                               |    2 
 63 files changed, 1,742 insertions(+), 330 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/config/buttons.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/config/buttons.js"
index 890cd2d..1062dd4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/config/buttons.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/config/buttons.js"
@@ -80,6 +80,15 @@
     onClick: function () {
         this.upload();
     }
+}, {
+    name: "瀹屾垚宸ュ崟",
+    icon: 'el-icon-check',
+    type: 'success',
+    plain: true,
+    value: 'FinishWorkOrder',
+    onClick: function () {
+        // this.FinishWorkOrder();
+    }
 }
     // , {
     //     name: "鏁版嵁缁撴瀯",
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/api/http.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/api/http.js"
index 8ecd457..f6b7a14 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/api/http.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/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://127.0.0.1:8099/';
+    axios.defaults.baseURL = 'http://192.168.12.101:8099/';
 }
 else if (process.env.NODE_ENV == 'debug') {
     axios.defaults.baseURL = 'http://192.168.12.101:8099/';
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_system/system/dt_log_pcs.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_system/system/dt_log_pcs.js"
index 91cef30..ceb4b2b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_system/system/dt_log_pcs.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_system/system/dt_log_pcs.js"
@@ -20,9 +20,12 @@
 
       //榛樿鏌ヨ鍓�7澶╂棩蹇�
       let dateNow = this.base.getDate(true);
-      let beginDate = this.base.addDays(dateNow, -7);
+      // let beginDate = this.base.addDays(dateNow, -7);
+      let beginDate = this.base.addDays(dateNow, 0);
       beginDate = beginDate.substring(0, 11) + '00:00:00'
-      let startDate = this.base.addDays(dateNow, 1);
+      // let startDate = this.base.addDays(dateNow, 1);
+      let startDate = this.base.addDays(dateNow, 1);//鏌ヨ褰撳ぉ鏃ュ織
+      startDate=startDate.substring(0, 11) + '00:00:00'
       this.searchFormFields.createtime = [beginDate, startDate];
 
       //鑷畾涔夊垪棰滆壊
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js"
index 8935403..b6fa96e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js"
@@ -32,6 +32,45 @@
         //       this.$Message.success('鐐瑰嚮浜嗘寜閽�');
         //     }
         //   });
+        // this.buttons.forEach(x => {
+        //   if(x.value == 'FinishWorkOrder')
+        //   {
+        //     x.name = '瀹屾垚宸ュ崟'
+        //     x.type='success'
+        //     x.icon= 'el-icon-check'
+        //   }
+        // });
+        let CompleteBtn = this.buttons.find(r => r.name == "瀹屾垚宸ュ崟");
+        if(null!=CompleteBtn){
+          CompleteBtn.onClick = function (){
+            let rows = this.$refs.table.getSelected();
+            if (rows.length == 0) return this.$error("璇烽�夋嫨宸ュ崟!");
+            let addkeys = rows.map(x => {
+                return x[this.table.key];
+            });
+            if (!addkeys || addkeys.Length == 0) return this.$error("娌℃湁鑾峰緱瑕佸畬鎴愮殑宸ュ崟!");
+            this.$confirm("鏄惁纭瑕佸畬鎴愬伐鍗曪紵","鎻愮ず",{
+                        // iconClass:"el-icon-success",//el-icon-remove鑷畾涔夊浘鏍囨牱寮�
+                        confirmButtonText:"纭",//纭鎸夐挳鏂囧瓧鏇存崲
+                        cancelButtonText:"鍙栨秷",//鍙栨秷鎸夐挳鏂囧瓧鏇存崲
+                        // cancelBtn:"鍙栨秷",//鍙栨秷鎸夐挳鏂囧瓧鏇存崲
+                        showClose: true,//鏄惁鏄剧ず鍙充笂瑙掑叧闂寜閽�
+                        type: "warning",//鎻愮ず绫诲瀷 success:鎴愬姛/info:淇℃伅/warning:璀﹀憡/error:鎶ラ敊
+            }).then(()=>{
+              let params = {
+                MainData: null,
+                DetailData: null,
+                DelKeys: addkeys
+            }
+            this.http.post("/api/dt_mes_head/FinishWorkOrder", params, "姝e湪瀹屾垚宸ュ崟....").then(x => {
+                if (!x.status) return this.$error(x.message);
+                this.$success("瀹屾垚宸ュ崟鎴愬姛!");
+                this.refresh();
+            });
+            })
+
+          }
+        }
 
         //绀轰緥锛氳缃慨鏀规柊寤恒�佺紪杈戝脊鍑烘瀛楁鏍囩鐨勯暱搴�
         // this.boxOptions.labelWidth = 150;
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/system/Sys_User.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/system/Sys_User.vue"
index 9e4e455..6eb78a2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/system/Sys_User.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/system/Sys_User.vue"
@@ -27,7 +27,7 @@
         const editFormOptions = ref([[{ "title": "甯愬彿", "required": true, "field": "UserName", "disabled": true }],
         [{ "title": "濮撳悕", "required": true, "field": "UserTrueName", "type": "text" }],
         [{ "dataKey": "tree_roles", "data": [], "title": "瑙掕壊", "required": true, "field": "Role_Id", "type": "cascader" }],
-        [{ "dataKey": "缁勭粐鏈烘瀯", "data": [], "title": "缁勭粐鏋勬灦", "field": "DeptIds", "colSize": 12, "type": "treeSelect" }],
+        // [{ "dataKey": "缁勭粐鏈烘瀯", "data": [], "title": "缁勭粐鏋勬灦", "field": "DeptIds", "colSize": 12, "type": "treeSelect" }],
         [{ "dataKey": "enable", "data": [], "title": "鏄惁鍙敤", "required": true, "field": "Enable", "type": "select" }],
         [{ "dataKey": "gender", "data": [], "title": "鎬у埆", "field": "Gender", "type": "select" }],
         [{ "title": "澶囨敞", "field": "Remark", "colSize": 12, "type": "textarea" }],
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data.vue"
index 28f8fa9..3f8d8da 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data.vue"
@@ -41,7 +41,7 @@
                               [{"title":"g","required":true,"field":"g","type":"text"},
                                {"title":"h","required":true,"field":"h","type":"text"}]]);
             const searchFormFields = ref({"TypeId":"","Description":""});
-            const searchFormOptions = ref([[{"title":"鍥惧彿","field":"Description","type":"like"},{"title":"","field":"TypeId","type":"like"}]]);
+            const searchFormOptions = ref([[{"title":"鍥惧彿","field":"Description","type":"like"},{"title":"TypeId","field":"TypeId","type":"int"}]]);
             const columns = ref([{field:'TypeId',title:'TypeId',type:'int',width:110,require:true,align:'left',sort:true},
                        {field:'Description',title:'鍥惧彿',type:'string',width:120,require:true,align:'left'},
                        {field:'a',title:'a',type:'float',width:110,require:true,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data_detectionline.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data_detectionline.vue"
index 502f291..fb9f422 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data_detectionline.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/baseinfo/dt_geometry_data_detectionline.vue"
@@ -56,7 +56,7 @@
                                {"title":"skip_14","field":"skip_14","type":"text"}],
                               [{"title":"skip_15","field":"skip_15","type":"text"}]]);
             const searchFormFields = ref({"TypeId":"","Description":""});
-            const searchFormOptions = ref([[{"title":"鍥惧彿","field":"Description","type":"like"},{"title":"","field":"TypeId","type":"like"}]]);
+            const searchFormOptions = ref([[{"title":"鍥惧彿","field":"Description","type":"like"},{"title":"TypeId","field":"TypeId","type":"int"}]]);
             const columns = ref([{field:'ID',title:'ID',type:'int',width:110,hidden:true,readonly:true,require:true,align:'left'},
                        {field:'TypeId',title:'TypeId',type:'int',width:110,require:true,align:'left',sort:true},
                        {field:'Description',title:'鍥惧彿',type:'string',width:120,require:true,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail.vue"
index 7cf8f41..e32c322 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail.vue"
@@ -31,7 +31,7 @@
             });
             const editFormFields = ref({});
             const editFormOptions = ref([]);
-            const searchFormFields = ref({"SN":"","jobID":""});
+            const searchFormFields = ref({"SN":"","jobID":"","heatID":"","billetID":""});
             const searchFormOptions = ref([[{"title":"杞﹁疆SN鍙�","field":"SN","type":"like"},{"title":"宸ュ崟缂栧彿","field":"jobID","type":"like"}],
             [{"title":"鐐変唬鍙�","field":"heatID","type":"like"},{"title":"閽㈠澂鍙�","field":"billetID","type":"like"}]]);
             const columns = ref([{field:'mes_detail_id',title:'宸ュ崟鏄庣粏ID',type:'guid',width:110,hidden:true,readonly:true,require:true,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail_hty.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail_hty.vue"
index fe44d16..0d83de1 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail_hty.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_detail_hty.vue"
@@ -31,15 +31,17 @@
             });
             const editFormFields = ref({});
             const editFormOptions = ref([]);
-            const searchFormFields = ref({});
-            const searchFormOptions = ref([]);
+            const searchFormFields = ref({"SN":"","jobID":"","heatID":"","billetID":""});
+            const searchFormOptions = ref([[{"title":"杞﹁疆SN鍙�","field":"SN","type":"like"},{"title":"宸ュ崟缂栧彿","field":"jobID","type":"like"}],
+            [{"title":"鐐変唬鍙�","field":"heatID","type":"like"},{"title":"閽㈠澂鍙�","field":"billetID","type":"like"}]]);
             const columns = ref([{field:'mes_detail_id',title:'宸ュ崟鏄庣粏ID',type:'guid',width:110,hidden:true,readonly:true,require:true,align:'left'},
                        {field:'jobID',title:'宸ュ崟缂栧彿',type:'string',width:110,align:'left',sort:true},
-                       {field:'heatID',title:'鐐変唬鍙�',type:'string',width:110,align:'left'},
-                       {field:'billetID',title:'閽㈠澂鍙�',type:'int',width:110,require:true,align:'left'},
+                       {field:'heatID',title:'鐐変唬鍙�',type:'string',width:60,align:'left'},
+                       {field:'billetID',title:'閽㈠澂鍙�',type:'int',width:60,require:true,align:'left'},
                        {field:'SN',title:'杞﹁疆SN鍙�',type:'string',width:110,align:'left'},
                        {field:'heatBatchID',title:'鐑鐞嗘壒娆�',type:'string',width:110,align:'left'},
                        {field:'mes_headID',title:'宸ュ崟澶磋〃ID',type:'guid',width:110,align:'left'},
+                       {field:'Status',title:'宸ュ崟鐘舵��',type:'string',width:60,align:'left'},
                        {field:'FinishTime',title:'瀹屾垚鏃堕棿',type:'datetime',width:150,align:'left',sort:true},
                        {field:'operatetype',title:'鎿嶄綔绫诲瀷',type:'string',width:110,align:'left'},
                        {field:'compeletor',title:'鎿嶄綔鑰�',type:'string',width:110,align:'left'}]);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head.vue"
index e0442b0..c410b72 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head.vue"
@@ -22,19 +22,23 @@
     export default defineComponent({
         setup() {
             const table = ref({
-                key: 'ID',
+                key: 'mes_id',
                 footer: "Foots",
                 cnName: '宸ュ崟澶磋〃',
                 name: 'tomes/dt_mes_head',
                 url: "/dt_mes_head/",
                 sortName: "ID"
             });
-            const editFormFields = ref({});
-            const editFormOptions = ref([]);
+            const editFormFields = ref({"skip_op_1":"","skip_op_2":"","skip_op_3":""});
+            const editFormOptions = ref([
+            [{ "dataKey": "skip_op_Status", "data": [], "title": "瑙嗚妫�娴�1", "required": true, "field": "skip_op_1", "type": "select" }],
+            [{ "dataKey": "skip_op_Status", "data": [], "title": "瑙嗚妫�娴�2", "required": true, "field": "skip_op_2", "type": "select" }],
+            [{ "dataKey": "skip_op_Status", "data": [], "title": "鍠烽槻閿堟恫", "required": true, "field": "skip_op_3", "type": "select" }]
+            ]);
             const searchFormFields = ref({"jobID":"","processCode":"","CreateTime":""});
             const searchFormOptions = ref([
                 [{"title":"宸ュ崟缂栧彿","field":"jobID","type":"like"},{"dataKey":"WorkTypes","data":[],"title":"宸ュ崟绫诲瀷","field":"processCode","type":"select"}],
-                [{"title":"鍒涘缓鏃堕棿","field":"CreateTime","type":"datetime"}]
+                [{"title":"鍥惧彿","field":"drawingNo","type":"like"},{"title":"鍒涘缓鏃堕棿","field":"CreateTime","type":"datetime"}]
             ]);
             const columns = ref([{field:'mes_id',title:'mes_id',type:'guid',width:110,hidden:true,readonly:true,require:true,align:'left'},
                        {field:'workOrder',title:'宸ヤ綔浠ゅ彿',type:'string',width:110,align:'left',sort:true},
@@ -50,8 +54,8 @@
                        {field:'finishNum',title:'瀹屾垚鏁伴噺',type:'int',width:110,align:'left'},
                        {field:'skip_op_1',title:'瑙嗚妫�娴�1',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
                        {field:'skip_op_2',title:'瑙嗚妫�娴�2',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
-                       {field:'skip_op_3',title:'閾炬潯鏈�',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
-                       {field:'area',title:'鍏ュ簱搴撳尯',type:'string',width:110,align:'left'},
+                       {field:'skip_op_3',title:'鍠烽槻閿堟恫',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
+                    //    {field:'area',title:'鍏ュ簱搴撳尯',type:'string',width:110,align:'left'},
                        {field:'typeID',title:'杞瀷浠g爜',type:'string',width:110,align:'left'},
                        {field:'stackNoRange',title:'鎵撳寘鏁伴噺',type:'int',width:110,align:'left'},
                        {field:'maxDiameterDiff',title:'杞緞鍋忓樊',type:'decimal',width:110,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head_hty.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head_hty.vue"
index ace91e9..023212c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head_hty.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Client/src/views/widesea_wcs/tomes/dt_mes_head_hty.vue"
@@ -31,8 +31,11 @@
             });
             const editFormFields = ref({});
             const editFormOptions = ref([]);
-            const searchFormFields = ref({});
-            const searchFormOptions = ref([]);
+            const searchFormFields = ref({"jobID":"","processCode":"","CreateTime":""});
+            const searchFormOptions = ref([
+                [{"title":"宸ュ崟缂栧彿","field":"jobID","type":"like"},{"dataKey":"WorkTypes","data":[],"title":"宸ュ崟绫诲瀷","field":"processCode","type":"select"}],
+                [{"title":"鍥惧彿","field":"drawingNo","type":"like"},{"title":"瀹屾垚鏃堕棿","field":"FinishTime","type":"datetime"}]
+            ]);
             const columns = ref([{field:'mes_id',title:'mes_id',type:'guid',width:110,hidden:true,readonly:true,require:true,align:'left'},
                        {field:'workOrder',title:'宸ヤ綔浠ゅ彿',type:'string',width:110,align:'left',sort:true},
                        {field:'jobID',title:'宸ュ崟缂栧彿',type:'string',width:110,align:'left'},
@@ -44,6 +47,7 @@
                        {field:'productName',title:'浜у搧鍚嶇О',type:'string',width:110,align:'left'},
                        {field:'productDesc',title:'浜у搧鎻忚堪',type:'string',width:180,align:'left'},
                        {field:'quantity',title:'璁″垝鏁伴噺',type:'int',width:110,require:true,align:'left'},
+                       {field:'finishNum',title:'瀹屾垚鏁伴噺',type:'int',width:110,align:'left'},
                        {field:'typeID',title:'杞瀷浠g爜',type:'string',width:110,align:'left'},
                        {field:'stackNoRange',title:'鎵撳寘鏁伴噺',type:'int',width:110,align:'left'},
                        {field:'maxDiameterDiff',title:'杞緞鍋忓樊',type:'decimal',width:110,align:'left'},
@@ -51,12 +55,11 @@
                        {field:'expectedFinishTime',title:'璁″垝瀹屾垚鏃堕棿',type:'datetime',width:150,align:'left',sort:true},
                        {field:'CreateTime',title:'鍒涘缓鏃堕棿',type:'datetime',width:150,align:'left',sort:true},
                        {field:'creator',title:'鍒涘缓鑰�',type:'string',width:100,align:'left'},
-                       {field:'processCode',title:'宸ュ崟绫诲瀷',type:'string',width:110,align:'left'},
-                       {field:'finishNum',title:'瀹屾垚鏁伴噺',type:'int',width:110,align:'left'},
+                       {field:'processCode',title:'宸ュ崟绫诲瀷',bind: { key: 'WorkTypes' },type:'string',width:110,align:'left'},
                        {field:'area',title:'鍏ュ簱鍖哄煙浠g爜',type:'string',width:110,align:'left'},
-                       {field:'skip_op_1',title:'瑙嗚妫�娴嬭澶�1',type:'bool',width:110,align:'left'},
-                       {field:'skip_op_2',title:'瑙嗚妫�娴嬭澶�2',type:'bool',width:110,align:'left'},
-                       {field:'skip_op_3',title:'閾炬潯鏈�',type:'bool',width:110,align:'left'},
+                       {field:'skip_op_1',title:'瑙嗚妫�娴�1',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
+                       {field:'skip_op_2',title:'瑙嗚妫�娴�2',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
+                       {field:'skip_op_3',title:'鍠烽槻閿堟恫',type:'bool',bind:{ key:'skip_op_Status',data:[]},width:110,require:true,align:'left'},
                        {field:'FinishTime',title:'瀹屾垚鏃堕棿',type:'datetime',width:150,align:'left',sort:true},
                        {field:'operatetype',title:'鎿嶄綔绫诲瀷',type:'string',width:110,align:'left'},
                        {field:'compeletor',title:'鎿嶄綔鑰�',type:'string',width:110,align:'left'}]);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/LogInfo/WriteDBLog.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/LogInfo/WriteDBLog.cs"
index 5953ae3..2b15b90 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/LogInfo/WriteDBLog.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/LogInfo/WriteDBLog.cs"
@@ -6,9 +6,12 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_Comm.DBItem;
+using WIDESEA_Core.EFDbContext;
 using WIDESEA_Core.FreeDB;
 using WIDESEA_Core.ManageUser;
 using WIDESEA_Entity.DomainModels;
+using WIDESEA_System.IRepositories;
+using WIDESEA_System.Repositories;
 using WIDESEA_WCS.JobsPart.Common;
 
 namespace WIDESEA_Comm.LogInfo
@@ -88,7 +91,10 @@
         {
             try
             {
+                VOLContext context = new VOLContext();
+                Idt_log_pcsRepository pcsRepository = new dt_log_pcsRepository(context);
                 //dt_log log = new dt_log();
+
                 dt_log_pcs log = new dt_log_pcs();
                 log.id = Guid.NewGuid();
                 log.createtime = DateTime.Now;
@@ -105,7 +111,14 @@
                     log.info = JsonConvert.SerializeObject(info);
                 }
                 //StoredProcedure.Main(log, MethodName.Add);
-                StoredProcedure.EXECAdd(log, MethodName.Add);
+                //var data = pcsRepository.Find(x => x.dataForm == log.dataForm && x.describe == log.describe && x.status == log.status && x.info == log.info).FirstOrDefault();
+                //if (data == null)
+                    StoredProcedure.EXECAdd(log, MethodName.Add);
+                //else
+                //{
+                //    data.createtime = DateTime.Now;
+                //    pcsRepository.Update(data, true);
+                //}
                 //freeDB.Add(log);
             }
             catch (Exception ex)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
index 40a1beb..3d36761 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
@@ -44,6 +44,23 @@
         public string FigureNumber { get; set; }
 
         /// <summary>
+        ///鐗╂枡缂栫爜
+        /// </summary>
+        [Display(Name = "鐗╂枡缂栫爜")]
+        [MaxLength(20)]
+        [Column(TypeName = "nvarchar(20)")]
+        [Editable(true)]
+        public string materialCode { get; set; }
+
+        /// <summary>
+        ///鎶�鏈姸鎬�
+        /// </summary>
+        [Display(Name = "鎶�鏈姸鎬�")]
+        [MaxLength(10)]
+        [Column(TypeName = "nvarchar(10)")]
+        [Editable(true)]
+        public string drawingNoVer { get; set; }
+        /// <summary>
         ///鐔旂偧鐐夊彿
         /// </summary>
         //[Display(Name = "鐔旂偧鐐夊彿")]
@@ -120,7 +137,9 @@
         [Column(TypeName = "nvarchar(15)")]
         [Editable(true)]
         public string area { get; set; }
-
+        /// <summary>
+        /// 宸ヤ綔浠ゅ彿
+        /// </summary>
         [Display(Name = "宸ュ崟缂栧彿")]
         [Column(TypeName = "nvarchar(40)")]
         [Editable(true)]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_stationinfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_stationinfo.cs"
index 607e5ac..3acc2fa 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_stationinfo.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_stationinfo.cs"
@@ -128,7 +128,7 @@
         public int column { get; set; }
 
         /// <summary>
-        ///宸ュ崟缂栧彿
+        ///宸ュ崟缂栧彿/宸ヤ綔浠ゅ彿
         /// </summary>
         [Display(Name = "宸ュ崟缂栧彿")]
         [MaxLength(255)]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
index 9013d28..8c022c6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
@@ -85,7 +85,7 @@
         public string agv_taskstate { get; set; }
 
         /// <summary>
-        ///宸ュ崟绫诲瀷/AGV宸ヤ綔绫诲瀷
+        ///宸ュ崟绫诲瀷(17-鏈哄姞宸� 28-妫�娴嬬嚎 101绉诲簱澶栧崗)
         /// </summary>
         [Display(Name = "AGV宸ヤ綔绫诲瀷")]
         [Column(TypeName = "int")]
@@ -173,7 +173,7 @@
         public string agv_remark { get; set; }
 
         /// <summary>
-        ///浠诲姟绛夌骇  0銆佹殏缂�1銆佹甯�2銆佸姞鎬�
+        ///浠诲姟绛夌骇  0銆佹殏缂�1銆佹甯�2銆佸姞鎬� 3銆佺壒鎬�
         /// </summary>
         [Display(Name = "浠诲姟绛夌骇")]
         [Column(TypeName = "int")]
@@ -233,7 +233,7 @@
         public DateTime? agv_completeBeginTime { get; set; }
 
         /// <summary>
-        ///宸ュ崟鍙�
+        ///宸ュ崟鍙�/宸ヤ綔浠ゅ彿
         /// </summary>
         [Display(Name = "宸ュ崟鍙�")]
         [Column(TypeName = "nvarchar(40)")]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs"
new file mode 100644
index 0000000..52669ae
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs"
@@ -0,0 +1,164 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *濡傛灉鏁版嵁搴撳瓧娈靛彂鐢熷彉鍖栵紝璇峰湪浠g爜鐢熷櫒閲嶆柊鐢熸垚姝odel
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Entity.SystemModels;
+
+namespace WIDESEA_Entity.DomainModels
+{
+    [Entity(TableCnName = "宸ュ崟瑙嗗浘",TableName = "VV_Mes_Workinfo")]
+    public partial class VV_Mes_Workinfo:BaseEntity
+    {
+        /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="jobID")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string jobID { get; set; }
+
+       /// <summary>
+       ///鐐夊彿
+       /// </summary>
+       [Display(Name ="heatID")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string heatID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="billetID")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       public int? billetID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="SN")]
+       [MaxLength(50)]
+       [Column(TypeName="nvarchar(50)")]
+       [Editable(true)]
+       public string SN { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="heatBatchID")]
+       [MaxLength(30)]
+       [Column(TypeName="nvarchar(30)")]
+       [Editable(true)]
+       public string heatBatchID { get; set; }
+
+       /// <summary>
+       ///宸ヤ綔浠ゅ彿
+       /// </summary>
+       [Display(Name ="workOrder")]
+       [MaxLength(50)]
+       [Column(TypeName="nvarchar(50)")]
+       [Editable(true)]
+       public string workOrder { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="reqID")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string reqID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="reqIDLineNo")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string reqIDLineNo { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="materialCode")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string materialCode { get; set; }
+
+       /// <summary>
+       ///鍥惧彿
+       /// </summary>
+       [Display(Name ="drawingNo")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string drawingNo { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="drawingNoVer")]
+       [MaxLength(10)]
+       [Column(TypeName="nvarchar(10)")]
+       [Editable(true)]
+       public string drawingNoVer { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="productName")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string productName { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="quantity")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       public int quantity { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="typeID")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string typeID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Key]
+       [Display(Name ="stackNoRange")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       [Required(AllowEmptyStrings=false)]
+       public int stackNoRange { get; set; }
+
+       /// <summary>
+       ///宸ュ崟绫诲瀷 (17-鏈哄姞宸� 28-妫�娴嬬嚎 101绉诲簱澶栧崗)
+       /// </summary>
+       [Display(Name ="processCode")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string processCode { get; set; }
+
+       
+    }
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs"
new file mode 100644
index 0000000..c07f48b
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs"
@@ -0,0 +1,21 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *濡傛灉鏁版嵁搴撳瓧娈靛彂鐢熷彉鍖栵紝璇峰湪浠g爜鐢熷櫒閲嶆柊鐢熸垚姝odel
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Entity.SystemModels;
+
+namespace WIDESEA_Entity.DomainModels
+{
+    
+    public partial class VV_Mes_Workinfo
+    {
+        //姝ゅ閰嶇疆瀛楁(瀛楁閰嶇疆瑙佹model鐨勫彟涓�涓猵artial),濡傛灉琛ㄤ腑娌℃湁姝ゅ瓧娈佃鍔犱笂 [NotMapped]灞炴�э紝鍚﹀垯浼氬紓甯�
+    }
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
index f78df0c..9cc2340 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
@@ -11,6 +11,7 @@
 using WIDESEA_Comm.LogInfo;
 using WIDESEA_Comm.TaskNo;
 using WIDESEA_Core.EFDbContext;
+using WIDESEA_Core.FreeDB;
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_WCS.IRepositories;
 using WIDESEA_WCS.JobsPart.Common;
@@ -37,6 +38,7 @@
                 VOLContext Context = new VOLContext();
                 Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
                 Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
+                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
                 Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
                 Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
                 Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
@@ -56,32 +58,47 @@
                         if (name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ杞﹁疆") number = "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟";
                         if (name == "杈婇亾涓婃枡鏌ヨ杞﹁疆") number = "杈婇亾涓婃枡鏌ヨ璁㈠崟";
                         var wp_id = client.ReadByOrder<string>("R_o_wp_id", number);
-                        var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id);
-                        if (mes_Detail == null)
+
+                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆" ? "17" : "28")).FirstOrDefault();
+                        if (Mes_Work == null)
                         {
                             client.WriteByOrder("W_i_status", (byte)2, name);
                             client.WriteByOrder("R_oi_on", (byte)0, name);
                             #region 鏃ュ織璁板綍
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
-                            #endregion
-                            continue;
-                        }
-                        var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
-                        if (mes_Head == null)
-                        {
-                            client.WriteByOrder("W_i_status", (byte)2, name);
-                            client.WriteByOrder("R_oi_on", (byte)0, name);
-                            #region 鏃ュ織璁板綍
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
+                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS");
                             #endregion
                             continue;
                         }
 
+                        #region MyRegion
+                        //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id);
+                        //if (mes_Detail == null)
+                        //{
+                        //    client.WriteByOrder("W_i_status", (byte)2, name);
+                        //    client.WriteByOrder("R_oi_on", (byte)0, name);
+                        //    #region 鏃ュ織璁板綍
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
+                        //if (mes_Head == null)
+                        //{
+                        //    client.WriteByOrder("W_i_status", (byte)2, name);
+                        //    client.WriteByOrder("R_oi_on", (byte)0, name);
+                        //    #region 鏃ュ織璁板綍
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        #endregion
+
+
                         if (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆")
                         {
                             //var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type);
-                            var geometry = dataRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault();
-                            var geometry1 = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault();
+                            var geometry = dataRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault();
+                            var geometry1 = detectionlineRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault();
                             if (geometry == null && geometry1 == null)
                             {
                                 //DBExtension.Write(details.Where(x => x.plcdetail_name == "W_i_status").First(), client, (Int16)2);
@@ -121,8 +138,8 @@
                         }
                         else
                         {
-                            var geometry = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault();
-                            var geometry1 = dataRepository.Find(x => x.Description == mes_Head.drawingNo).FirstOrDefault();
+                            var geometry = detectionlineRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault();
+                            var geometry1 = dataRepository.Find(x => x.Description == Mes_Work.drawingNo).FirstOrDefault();
                             if (geometry == null && geometry1 == null)
                             {
                                 client.WriteByOrder("W_i_status", (byte)2, name);
@@ -183,6 +200,7 @@
                 Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
                 Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
                 Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
+                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
                 Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
                 Idt_patternRepository patternRepository = new dt_patternRepository(Context);
                 var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
@@ -206,16 +224,9 @@
                             continue;
                         }
                         var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client);
-                        var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id);
-                        #region 娴嬭瘯浣跨敤
-                        //if (mes_Detail == null)
-                        //{
-                        //    mes_Detail = mes_DetailRepository.FindFirst(x => x.jobID == (name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? "01180127004-2" : "01180127004-1"));
-                        //    mes_Detail.SN = wp_id;
-                        //    mes_DetailRepository.Update(mes_Detail, true);
-                        //}
-                        #endregion
-                        if (mes_Detail == null)
+
+                        var Mes_Work = workinfoRepository.Find(x => x.SN == wp_id && x.processCode == (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟" ? "17" : "28")).FirstOrDefault();
+                        if (Mes_Work == null)
                         {
                             client.WriteByOrder("W_i_status", (byte)2, name);
                             client.WriteByOrder("R_oi_on", (byte)0, name);
@@ -224,16 +235,30 @@
                             #endregion
                             continue;
                         }
-                        var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
-                        if (mes_Head == null)
-                        {
-                            client.WriteByOrder("W_i_status", (byte)2, name);
-                            client.WriteByOrder("R_oi_on", (byte)0, name);
-                            #region 鏃ュ織璁板綍
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
-                            #endregion
-                            continue;
-                        }
+                        #region MyRegion
+                        //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id);
+                        //if (mes_Detail == null)
+                        //{
+                        //    client.WriteByOrder("W_i_status", (byte)2, name);
+                        //    client.WriteByOrder("R_oi_on", (byte)0, name);
+                        //    #region 鏃ュ織璁板綍
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
+                        //if (mes_Head == null)
+                        //{
+                        //    client.WriteByOrder("W_i_status", (byte)2, name);
+                        //    client.WriteByOrder("R_oi_on", (byte)0, name);
+                        //    #region 鏃ュ織璁板綍
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�2\nR_oi_on锛�0\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        #endregion
+
+                        var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == Mes_Work.jobID);
 
                         if (name != "杈婇亾涓婃枡鏌ヨ璁㈠崟")
                         {
@@ -265,11 +290,11 @@
                             {
                                 //1-濂�,鍏佽鍔犲伐锛�2-涓嶅湪鍒楄〃涓紝3-涓嶅姞宸ヨ溅杞被鍨嬶紝4-鎵嬪姩鍏ュ簱妯″紡浜哄伐鏈�夋嫨搴撳尯
                                 client.WriteByOrder("W_i_status", (byte)1, name);
-                                client.WriteByOrder("W_i_job_id", mes_Detail.jobID, name);
-                                client.WriteByOrder("W_i_drawing_id", mes_Head.drawingNo, name);
-                                client.WriteByOrder("W_i_heat_id", mes_Detail.heatID, name);
+                                client.WriteByOrder("W_i_job_id", Mes_Work.jobID, name);
+                                client.WriteByOrder("W_i_drawing_id", Mes_Work.drawingNo, name);
+                                client.WriteByOrder("W_i_heat_id", Mes_Work.heatID, name);
                                 //client.WriteByOrder("W_i_sourceheat", "", name);
-                                client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name);
+                                client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name);
 
                                 //灞忚斀宸ヨ壓(灞忚斀瑙嗚妫�娴�/灞忚斀娑傛补)
                                 //if (name != "杈婇亾涓婃枡鏌ヨ杞﹁疆")
@@ -281,7 +306,7 @@
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
                                 WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" +
-                                    $"\nW_i_job_id锛歿mes_Detail.jobID}\nW_i_drawing_id锛歿mes_Head.drawingNo}\nW_i_heat_id锛歿mes_Detail.heatID}\nW_i_batch_id锛歿mes_Detail.heatBatchID}" +
+                                    $"\nW_i_job_id锛歿Mes_Work.jobID}\nW_i_drawing_id锛歿Mes_Work.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}" +
                                     $"\nW_i_skip_op_SJ1锛歿(name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2锛歿(name == "3鍗曞厓杈婇亾涓嬫枡鏌ヨ璁㈠崟" ? true : mes_Head.skip_op_2)}" +
                                     $"\nW_i_skip_op_LT锛歿mes_Head.skip_op_3}\nR_oi_on锛�0", "PCS");
                                 #endregion
@@ -305,15 +330,15 @@
                             {
                                 //1-濂�,鍏佽鍔犲伐锛�2-涓嶅湪鍒楄〃涓紝3-涓嶅姞宸ヨ溅杞被鍨嬶紝4-鎵嬪姩鍏ュ簱妯″紡浜哄伐鏈�夋嫨搴撳尯
                                 client.WriteByOrder("W_i_status", (byte)1, name);
-                                client.WriteByOrder("W_i_job_id", mes_Detail.jobID, name);
-                                client.WriteByOrder("W_i_drawing_id", mes_Head.drawingNo, name);
-                                client.WriteByOrder("W_i_heat_id", mes_Detail.heatID, name);
+                                client.WriteByOrder("W_i_job_id", Mes_Work.jobID, name);
+                                client.WriteByOrder("W_i_drawing_id", Mes_Work.drawingNo, name);
+                                client.WriteByOrder("W_i_heat_id", Mes_Work.heatID, name);
                                 //client.WriteByOrder("W_i_sourceheat", "", name);
-                                client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name);
+                                client.WriteByOrder("W_i_batch_id", Mes_Work.heatBatchID, name);
                                 client.WriteByOrder("R_oi_on", (byte)0, name);
                                 #region 鏃ュ織璁板綍
-                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\nW_i_job_id锛歿mes_Detail.jobID}" +
-                                    $"\nW_i_drawing_id锛歿mes_Head.drawingNo}\nW_i_heat_id锛歿mes_Detail.heatID}\nW_i_batch_id锛歿mes_Detail.heatBatchID}\nR_oi_on锛�0", "PCS");
+                                WriteDBLog.Success(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿wp_id}\n杞瀷ID锛歿wp_type}\n\n鍐欏叆妗佹灦淇℃伅锛歕nW_i_status锛�1" + $"\nW_i_job_id锛歿Mes_Work.jobID}" +
+                                    $"\nW_i_drawing_id锛歿mes_Head.drawingNo}\nW_i_heat_id锛歿Mes_Work.heatID}\nW_i_batch_id锛歿Mes_Work.heatBatchID}\nR_oi_on锛�0", "PCS");
                                 #endregion
                             }
                         }
@@ -344,6 +369,7 @@
                 Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
                 Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
                 Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
+                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
                 Idt_patternRepository patternRepository = new dt_patternRepository(Context);
                 var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
                 var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "閾炬潯鏈�");
@@ -405,28 +431,38 @@
                             var Wheel_SN = client.ReadByOrder<string>("R_Wheel_id", name);//杞﹁疆SN鍙�
                             if (string.IsNullOrEmpty(Wheel_SN))
                             {
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙蜂负绌�", "PCS");
+                                WriteDBLog.Error(name + "鏀炬枡瀹屾垚", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙蜂负绌�", "PCS");
                                 continue;
                             }
 
                             //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();
-
-                            var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN);
-                            if (Detail == null)
+                            var Mes_Work = workinfoRepository.Find(x => x.SN == Wheel_SN && x.processCode == "17").FirstOrDefault();
+                            if (Mes_Work == null)
                             {
                                 #region 鏃ュ織璁板綍
                                 WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
                                 #endregion
                                 continue;
                             }
-                            var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17");
-                            if (Head == null)
-                            {
-                                #region 鏃ュ織璁板綍
-                                WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃{Detail.jobID}", "PCS");
-                                #endregion
-                                continue;
-                            }
+                            #region MyRegion
+                            //var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN);
+                            //if (Detail == null)
+                            //{
+                            //    #region 鏃ュ織璁板綍
+                            //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                            //    #endregion
+                            //    continue;
+                            //}
+                            //var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17");
+                            //if (Head == null)
+                            //{
+                            //    #region 鏃ュ織璁板綍
+                            //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_SN}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃{Detail.jobID}", "PCS");
+                            //    #endregion
+                            //    continue;
+                            //}
+                            #endregion
+
                             #endregion
 
                             var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client);
@@ -448,9 +484,9 @@
                             station.quantity++;
                             if (station.quantity == 1)
                             {
-                                station.stationType = Head.drawingNo;
-                                station.Number = Head.jobID;
-                                station.heatNumber = Detail.heatID;
+                                station.stationType = Mes_Work.drawingNo;
+                                station.Number = Mes_Work.workOrder;
+                                station.heatNumber = Mes_Work.heatID;
                                 station.tray_status = "StrogeTray";
                             }
 
@@ -473,11 +509,13 @@
                             //client.WriteByOrder("W_Enabl_Load", false, name);//鏄惁鍏佽
 
                             #region 淇敼宸ュ崟鐘舵��
+                            var Detail = mes_DetailRepository.FindFirst(x => x.jobID == Mes_Work.jobID && x.SN == Mes_Work.SN);
                             Detail.Status = "涓嬬嚎";
                             Detail.FinishTime = DateTime.Now;
                             count = mes_DetailRepository.Update(Detail, true);
                             if (count < 1)
                                 throw new Exception($"宸ュ崟瀛愯〃淇℃伅鏇存柊澶辫触锛佽溅杞甋N鍙凤細{Detail.SN}");
+                            var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID);
                             Head.finishNum = Head.finishNum + 1;
                             count = mes_HeadRepository.Update(Head, true);
                             if (count < 1)
@@ -505,30 +543,40 @@
                         var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client);
                         if (!Request) continue;
 
+                        var load_zone = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_zone").First(), client);
                         #region 璇诲彇妗佹灦淇℃伅
                         var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//杞﹁疆绫诲瀷
                         var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//杞﹁疆SN鍙�
                         if (string.IsNullOrEmpty(Wheel_id)) continue;
-                        //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();
 
-                        var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id);
-                        if (mes_Detail == null)
+                        var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault();
+                        if (Work == null)
                         {
-                            #region 鏃ュ織璁板綍
                             client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
-                            #endregion
-                            continue;
+                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟淇℃伅", "PCS");
                         }
-                        var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
-                        if (mes_Head == null)
-                        {
-                            #region 鏃ュ織璁板綍
-                            client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                            WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
-                            #endregion
-                            continue;
-                        }
+
+                        #region MyRegion
+                        //var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id);
+                        //if (mes_Detail == null)
+                        //{
+                        //    #region 鏃ュ織璁板綍
+                        //    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟璇︽儏", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        //var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
+                        //if (mes_Head == null)
+                        //{
+                        //    #region 鏃ュ織璁板綍
+                        //    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                        //    WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n\n鏈煡璇㈠埌宸ュ崟澶磋〃", "PCS");
+                        //    #endregion
+                        //    continue;
+                        //}
+                        #endregion
+
                         #endregion
 
 
@@ -538,11 +586,12 @@
                         if (name == "2鍗曞厓涓嬫枡鍖�") NGStation = "X02001003";
                         if (name == "3鍗曞厓涓嬫枡鍖�") NGStation = "X03001002";
 
-                        foreach (var station in Stations)     //浠讳綍涓�涓笅鏂欎綅涓虹┖鎴栫鐢ㄦ椂,閮戒細鍋滄妗佹灦
-                        {
-                            if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString())
-                                client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                        }
+                        //foreach (var station in Stations)     //浠讳綍涓�涓笅鏂欎綅涓虹┖鎴栫鐢ㄦ椂,閮戒細鍋滄妗佹灦
+                        //{
+                        //    if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString())
+                        //        client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                        //}
+
                         #region MyRegion
                         //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client);
                         //var currentAreaCode = PipelineJob.area_code(name);   //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜
@@ -552,8 +601,8 @@
                         #endregion
 
 
-                        var wheel = PipelineJob.QueryMateriel(mes_Head.drawingNo);
-                        var wheel1 = PipelineJob.QueryMateriel1(mes_Head.drawingNo);
+                        var wheel = PipelineJob.QueryMateriel(Work.drawingNo);
+                        var wheel1 = PipelineJob.QueryMateriel1(Work.drawingNo);
                         if (wheel == null && wheel1 == null)
                         {
                             #region 鏃ュ織璁板綍
@@ -565,22 +614,23 @@
 
                         var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
                         #region 鏃ュ織璁板綍
-                        WriteDBLog.Success(name + "鐢宠鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細{PartStatus}", "PCS");
+                        WriteDBLog.Success(name + "鐢宠鏀炬枡", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN锛歿Wheel_id}\n杞瀷ID锛歿Wheel_Type}\n杞﹁疆鐘舵�侊細{PartStatus}\n鏄惁杩涘叆涓嬫枡鍖猴細{load_zone}", "PCS");
+                        if (load_zone) continue;
                         #endregion
                         if ((Int16)PartStatus == 1)
                         {
                             dt_stationinfo Stationinfo = null;
-                            if (mes_Detail.heatID != null)
+                            if (Work.heatID != null)
                             {
                                 Stationinfo = Stations
                            .Where(x => x.enable
                            && x.stationCode != NGStation
                            && x.location_state == LocationStateEnum.Stroge.ToString()
                            && x.quantity < 5
-                           && x.stationType == mes_Head.drawingNo
+                           && x.stationType == Work.drawingNo
                            && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")
-                           && x.Number == mes_Detail.jobID
-                           && x.heatNumber == mes_Detail.heatID)
+                           && x.Number == Work.workOrder
+                           && x.heatNumber == Work.heatID)
                            .OrderByDescending(x => x.quantity)
                            .FirstOrDefault();
                             }
@@ -591,9 +641,9 @@
                            && x.stationCode != NGStation
                            && x.location_state == LocationStateEnum.Stroge.ToString()
                            && x.quantity < 5
-                           && x.stationType == mes_Head.drawingNo
+                           && x.stationType == Work.drawingNo
                            && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")
-                           && x.Number == mes_Detail.jobID)
+                           && x.Number == Work.workOrder)
                            .OrderByDescending(x => x.quantity)
                            .FirstOrDefault();
                             }
@@ -613,23 +663,12 @@
                                 var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
                                 if (NG != null)
                                 {
-                                    if (NG.stationType != mes_Head.drawingNo)
-                                        agvtask(stationinfoRepository, NG, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound");
+                                    if (NG.stationType != Work.drawingNo || NG.Number != Work.workOrder)
+                                        agvtask(stationinfoRepository, NG, Work, "TaskType_OutsourceInbound");
                                 }
                                 #endregion
 
                                 Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
-
-                                #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟
-                                if (Stationinfo == null)
-                                {
-                                    var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList();
-                                    foreach (var stationinfo in stationinfos)
-                                    {
-                                        agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
-                                    }
-                                }
-                                #endregion
 
                                 #region MyRegion
                                 //var stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
@@ -675,9 +714,23 @@
 
                                     #region 璐т綅鏁伴噺涓庡厜鐢典笉鍖归厤锛屾姤璀�
                                     if (list.Count > 0 && MaterialSignal != 1)
+                                    {
+                                        client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
                                         Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
-                                    //else if (list.Count < 1 && MaterialSignal == 1)
-                                    //    Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
+                                        Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
+                                        Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤";
+                                        stationinfoRepository.Update(Stationinfo, true);
+                                        //WriteDBLog.Error(name+"鐢宠涓嬫枡",$"{Stationinfo.stationCode}鐨勮揣浣�","PCS");
+                                    }
+                                    else if (list.Count < 1 && MaterialSignal == 1)
+                                    {
+                                        client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                                        Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
+                                        Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
+                                        Stationinfo.remark = "杞﹁疆鏁伴噺涓庡厜鐢典笉鍖归厤";
+                                        stationinfoRepository.Update(Stationinfo, true);
+                                    }
+
                                     #endregion
 
                                     //缂撳瓨鏋朵笂杞﹁疆鏁伴噺涓嶴N鍙锋暟閲忎笉涓�鑷�
@@ -703,6 +756,17 @@
                                     continue;
                                 }
                             }
+                            else
+                            {
+                                #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟
+                                var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList();
+                                foreach (var stationinfo in stationinfos)
+                                {
+                                    agvtask(stationinfoRepository, stationinfo, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
+                                }
+                                #endregion
+                            }
+
                         }
                         else if ((Int16)PartStatus == 2)
                         {
@@ -728,18 +792,18 @@
                         && x.stationCode == NGStation
                         && x.location_state == LocationStateEnum.Stroge.ToString()
                         && x.quantity < 5
-                        && x.stationType == mes_Head.drawingNo
+                        && x.stationType == Work.drawingNo
                         && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray")
                         /*&& x.Number == mes_Detail.jobID*/).FirstOrDefault();
                             //}
 
                             if (Stationinfo == null)
                             {
-                                var stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
-                                if (stationinfo != null)
-                                {
-                                    agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound");
-                                }
+                                //var stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault();
+                                //if (stationinfo != null)
+                                //{
+                                //    agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound");
+                                //}
                                 Stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
                             }
                             if (Stationinfo != null)
@@ -772,8 +836,8 @@
                                     #region 璐т綅鏁伴噺涓庡厜鐢典笉鍖归厤锛屾姤璀�
                                     if (list.Count > 0 && MaterialSignal != 1)
                                         Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
-                                    //else if (list.Count < 1 && MaterialSignal == 1)
-                                    //    Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
+                                    else if (list.Count < 1 && MaterialSignal == 1)
+                                        Pipeline_client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//鎶ヨ
                                     #endregion
 
                                     //缂撳瓨鏋朵笂杞﹁疆鏁伴噺涓嶴N鍙锋暟閲忎笉涓�鑷�
@@ -870,7 +934,7 @@
         /// <summary>
         /// AGV浠诲姟
         /// </summary>
-        public void agvtask(Idt_stationinfoRepository stationinfoRepository, dt_stationinfo stationinfo, float e, string tasktype)
+        public void agvtask(Idt_stationinfoRepository stationinfoRepository, dt_stationinfo stationinfo, VV_Mes_Workinfo Work, string tasktype)
         {
             VOLContext Context = new VOLContext();
             Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
@@ -878,23 +942,24 @@
 
             var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault();
             if (task != null) return;
-            var mes_Head = mes_HeadRepository.Find(x => x.jobID == stationinfo.Number).FirstOrDefault();
-            if (mes_Head == null)
-            {
-                stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�";
-                stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
-                stationinfoRepository.Update(stationinfo, true);
-                return;
-            }
+            //var mes_Head = mes_HeadRepository.Find(x => x.jobID == Work.jobID).FirstOrDefault();
+            //if (mes_Head == null)
+            //{
+            //    stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�";
+            //    stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
+            //    stationinfoRepository.Update(stationinfo, true);
+            //    return;
+            //}
 
             dt_stationinfo TargetLocation = null;
-            int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum);
-            if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound";
+            //int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum);
+            //if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound";
 
             if (tasktype == "TaskType_OutsourceInbound")
                 TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository);
             else if (tasktype == "TaskType_Inbound")
-                TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository, mes_Head, stationinfo, CompeletedNum, e);
+                TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, Work, stationinfo);
+            //TargetLocation = GetLocation.GetEmptyLocation(stationinfoRepository, mes_Head, stationinfo);
             if (TargetLocation != null)
             {
                 dt_agvtask agvtask = new dt_agvtask()
@@ -911,8 +976,8 @@
                     agv_toaddress = TargetLocation.stationCode,
                     agv_userid = "绯荤粺",
                     bindSN = stationinfo.bindSN,
-                    agv_worktype = Convert.ToInt32(mes_Head.processCode),
-                    agv_materbarcode = mes_Head.materialCode,
+                    agv_worktype = Convert.ToInt32(Work.processCode),
+                    agv_materbarcode = Work.materialCode,
                     agv_Traytype = stationinfo.tray_type,
                     jobID = stationinfo.Number,
                     agv_TrayStatus = stationinfo.tray_status
@@ -922,6 +987,8 @@
                 stationinfoRepository.Update(stationinfo, true);
                 TargetLocation.location_state = LocationStateEnum.InBusy.ToString();
                 TargetLocation.stationType = agvtask.agv_materielid;
+                TargetLocation.heatNumber = stationinfo.heatNumber;
+                TargetLocation.Number = agvtask.jobID;
                 stationinfoRepository.Update(TargetLocation, true);
             }
         }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs"
new file mode 100644
index 0000000..be7c61b
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs"
@@ -0,0 +1,18 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *Repository鎻愪緵鏁版嵁搴撴搷浣滐紝濡傛灉瑕佸鍔犳暟鎹簱鎿嶄綔璇峰湪褰撳墠鐩綍涓婸artial鏂囦欢澶笽VV_Mes_WorkinfoRepository缂栧啓鎺ュ彛
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_Core.Extensions.AutofacManager;
+namespace WIDESEA_WMS.IRepositories
+{
+    public partial interface IVV_Mes_WorkinfoRepository : IDependency,IRepository<VV_Mes_Workinfo>
+    {
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/IVV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/IVV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..4211a9e
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/IVV_Mes_WorkinfoService.cs"
@@ -0,0 +1,12 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ */
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.IServices
+{
+    public partial interface IVV_Mes_WorkinfoService : IService<VV_Mes_Workinfo>
+    {
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..a8cedcb
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs"
@@ -0,0 +1,13 @@
+/*
+*鎵�鏈夊叧浜嶸V_Mes_Workinfo绫荤殑涓氬姟浠g爜鎺ュ彛搴斿湪姝ゅ缂栧啓
+*/
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_Core.Utilities;
+using System.Linq.Expressions;
+namespace WIDESEA_WMS.IServices
+{
+    public partial interface IVV_Mes_WorkinfoService
+    {
+    }
+ }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs"
index cea31a9..323e385 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs"
@@ -9,5 +9,11 @@
 {
     public partial interface Idt_mes_headService
     {
+        /// <summary>
+        /// 鎵嬪姩瀹屾垚宸ュ崟
+        /// </summary>
+        /// <param name="saveModel"></param>
+        /// <returns></returns>
+        WebResponseContent FinishWorkOrder(SaveModel saveModel);
     }
  }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
index 27aa48e..925e098 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
@@ -33,7 +33,8 @@
             //throw new NotImplementedException();
             //Creation.PLCinfodetail();
             //ReplaceTray.a();
-            //EmptyTrayTask.InEmptyTrayTask();搴撳唴绌烘墭浠诲姟
+            //EmptyTrayTask.InEmptyTrayTask(); //搴撳唴绌烘墭浠诲姟
+            //EmptyTrayTask.task();
 
             StationTask.CreateTask();
             //OutboundTask.CreateOutboundTask();
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs"
index b452b93..64c0e42 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs"
@@ -79,11 +79,11 @@
                 ///鏌ユ壘涓婃枡鍖虹殑璐т綅
                 var Stations = stationinfoRepository.Find(x => x.area == area_code(number));
                 //缂撳瓨鏋舵湭鍚敤绂佹妗佹灦杩涘叆
-                foreach (var station in Stations)
-                {
-                    if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString())
-                        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                }
+                //foreach (var station in Stations)
+                //{
+                //    if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString())
+                //        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                //}
 
                 var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault();
                 if (Station != null)
@@ -140,10 +140,10 @@
                         var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//淇℃伅纭
                         if (!Date_Vaild)//淇℃伅鏈夎锛岃褰曟棩蹇�
                         {
+                            Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
                             Station.location_state = LocationStateEnum.Abnormal.ToString();
                             Station.remark = $"鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗�";
                             stationinfoRepository.Update(Station, true);
-                            Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
                             //throw new Exception($"鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗曪紝涓婃枡浣嶇紪鍙凤細{Station.stationCode}");
                             WriteDBLog.Error("涓婃枡鍖轰俊鎭煡璇�", $"鍐欏叆妗佹灦淇℃伅锛歕nW_RequestUnload锛歠alse\n\n{Station.stationCode}鏈煡璇㈠埌SN鍙凤細{SNS[SNS.Length - 1]}鐨勮鍗�", "PCS");
                             return;
@@ -178,16 +178,23 @@
                         #region 鏃ュ織璁板綍
                         WriteDBLog.Success("鍙栨枡瀹屾垚", $"鍐欏叆妗佹灦淇℃伅锛歕n璐т綅鐘舵�佹洿鏂帮細{true}\nW_RequestUnload锛歿false}", "PCS");
                         #endregion
-                        //finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);
-                        //while (finished)
-                        //{
-                        //    finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);
-                        //    Gantry_client.WriteByOrder("W_Storage_update", false, number);//璐т綅鐘舵�佹洿鏂�
-                        //}
+                        PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃�
+                        MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃�
+                        if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1))
+                        {
+                            Station.location_state = LocationStateEnum.Abnormal.ToString();
+                            Station.remark = "杞﹁疆鏁伴噺澶т簬0锛屽厜鐢垫娴嬫棤鎵樼洏鎴栨棤杞﹁疆";
+                            stationinfoRepository.Update(Station, true);
+                            client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ
+                        }
+                        else if (Station.quantity < 1 && MaterialSignal == 1)
+                        {
+                            Station.location_state = LocationStateEnum.Abnormal.ToString();
+                            Station.remark = "杞﹁疆鏁伴噺灏忎簬0锛屽厜鐢垫娴嬫湁杞﹁疆";
+                            stationinfoRepository.Update(Station, true);
+                            client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//鎶ヨ
+                        }
                     }
-                    //else if (!finished && updatefinished)
-                    //    Gantry_client.WriteByOrder("W_Storage_update", false, number);//璐т綅鐘舵�佹洿鏂�
-
                 }
                 else
                     Gantry_client.WriteByOrder("W_RequestUnload", false, number);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
@@ -224,20 +231,37 @@
                     if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true))
                     {
                         var area = station.tray_type == "SmallTray" ? "11" : "10";
-                        var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" /*&& x.agv_tasktype == "TaskType_EmptyPallet" */ && x.agv_Traytype == station.tray_type).OrderBy(x => x.agv_createtime).FirstOrDefault();
+                        var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" /*&& x.agv_tasktype == "TaskType_EmptyPallet" */ && x.agv_Traytype == station.tray_type).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault();
                         if (task != null)
                         {
                             task.agv_fromaddress = station.stationCode;
                             task.StarQuantity = 0;
                             task.agv_taskstate = "Create";
+                            if (station.stationCode.Contains("S0100100"))
+                                task.agv_grade = 3;
                             agvtaskService.Update(task, true);
                             station.location_state = LocationStateEnum.Busy.ToString();
                             stationinfoRepository.Update(station, true);
                             continue;
 
                         }
+                        #region 鏌ユ壘搴撳尯涓�绌烘墭鐩樼┖璐т綅
                         var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity < 5 && x.stationCode.Contains("A") && x.location_state != LocationStateEnum.Busy.ToString() && x.enable)
-                        .OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault();
+                        .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;
+                            }
+                        }
+                        #endregion
+
                         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();//鏈�鍚庝竴涓揣浣嶆湁浠诲姟鍒欎笉鑳界敓鎴愬叆搴撲换鍔�
@@ -258,7 +282,7 @@
                                 agv_fromaddress = station.stationCode,
                                 agv_id = Guid.NewGuid(),
                                 agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
-                                agv_grade = 1,
+                                agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1,
                                 agv_createtime = DateTime.Now,
                                 agv_taskstate = "Create",
                                 //agv_materielid = station.stationType,
@@ -296,7 +320,7 @@
         {
             try
             {
-                List<string> names = new List<string>() { "1鍗曞厓涓嬫枡鍖�", "2鍗曞厓涓嬫枡鍖�", "3鍗曞厓涓嬫枡鍖�", "涓婃枡鍖�" };
+                List<string> names = new List<string>() { "1鍗曞厓涓嬫枡鍖�", "2鍗曞厓涓嬫枡鍖�", "3鍗曞厓涓嬫枡鍖�" };/*, "涓婃枡鍖�"*/
                 foreach (var name in names)
                 {
                     VOLContext Context = new VOLContext();
@@ -392,8 +416,10 @@
             VOLContext Context = new VOLContext();
             Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
             Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
+            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context);
             //var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == SN).First();
-            var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN).FirstOrDefault();
+            var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").FirstOrDefault();
+            var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN && x.jobID == Mes_Work.jobID).FirstOrDefault();
             if (mes_Detail != null)
             {
                 mes_Detail.Status = "涓婄嚎";
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
index 50e67dd..dc21fdb 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
@@ -82,7 +82,7 @@
                 foreach (var mes_head in mes_head_jjgs)
                 {
                     var inventorys = inventoryRepository.Find(x => x.jobID == mes_head.jobID).ToList();
-                    if (inventorys.Count == mes_head.finishNum)
+                    if (inventorys.Count == mes_head.quantity)
                         AddHtyMesWork(mes_head, mes_HeadRepository);
                 }
             }
@@ -92,7 +92,7 @@
         /// <summary>
         /// 宸插畬鎴愬伐鍗曠Щ鍏ュ巻鍙�
         /// </summary>
-        public static void AddHtyMesWork(dt_mes_head mes_Head, Idt_mes_headRepository mes_HeadRepository, string compeletor = "绯荤粺", string operatetype = "鑷姩瀹屾垚")
+        public static void AddHtyMesWork(dt_mes_head mes_Head, Idt_mes_headRepository mes_HeadRepository, string compeletor = "system", string operatetype = "鑷姩瀹屾垚")
         {
             try
             {
@@ -157,11 +157,11 @@
                 };
                 mes_Head_HtyRepository.Add(mes_Head_Hty, true);
                 mes_HeadRepository.Delete(mes_Head, true);
-                WriteDBLog.Success("澶勭悊宸插畬鎴愬伐鍗�", $"宸ュ崟缂栧彿锛歿mes_Head.jobID}", "PCS");
+                WriteDBLog.Success("澶勭悊宸插畬鎴愬伐鍗�", $"宸ュ崟缂栧彿锛歿mes_Head.jobID}", "PCS", compeletor);
             }
             catch (Exception ex)
             {
-                WriteDBLog.Error("澶勭悊宸插畬鎴愬伐鍗�", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                WriteDBLog.Error("澶勭悊宸插畬鎴愬伐鍗�", $"閿欒淇℃伅锛歿ex.Message}", "PCS", compeletor);
             }
         }
     }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/EmptyTrayTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/EmptyTrayTask.cs"
index d7e67a8..196578d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/EmptyTrayTask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/EmptyTrayTask.cs"
@@ -48,7 +48,7 @@
                             agv_fromaddress = "",
                             agv_id = Guid.NewGuid(),
                             agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
-                            agv_grade = 2,
+                            agv_grade = station.stationCode.Contains("W0100100") ? 3 : 2,
                             agv_createtime = DateTime.Now,
                             agv_taskstate = "Queue",
                             agv_qty = 1,
@@ -81,41 +81,69 @@
                 VOLContext context = new VOLContext();
                 Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                 Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
-                var stations = stationinfoRepository.Find(x => x.area == "2" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList();
-                if (stations.Count < 1)
-                {
-                    stations = stationinfoRepository.Find(x => x.area == "3" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList();
-                }
+                var stations = stationinfoRepository.Find(x => x.stationCode.Contains("C01004") && x.enable && x.location_state == LocationStateEnum.Stroge.ToString()).OrderByDescending(x => x.column).ToList();
+                //if (stations.Count < 1)
+                //{
+                //    stations = stationinfoRepository.Find(x => x.area == "3" && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).OrderBy(x => x.column).ToList();
+                //}
                 foreach (var station in stations)
                 {
-                    if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any())
+                    if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                         continue;
                     dt_agvtask taskPart = new dt_agvtask()
                     {
-                        agv_fromaddress = "",
+                        agv_fromaddress = station.stationCode,
                         agv_id = Guid.NewGuid(),
                         agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
-                        agv_grade = 2,
+                        agv_grade = 1,
                         agv_createtime = DateTime.Now,
                         agv_taskstate = "Queue",
+                        //agv_materielid = station.stationType,
                         agv_qty = 1,
+                        StarQuantity = 0,
+                        EndQuantity = 0,// EmptyStation.quantity,
                         agv_tasktype = "TaskType_EmptyPallet",
-                        agv_toaddress = station.stationCode,
+                        agv_toaddress = "",// EmptyStation.stationCode,
                         agv_userid = "绯荤粺",
-                        agv_TrayStatus = "EmptyTray",// station.tray_status, "SmallTray" : "LargeTray"
-                        agv_Traytype = station.area == "4" ? "LargeTray" : "SmallTray",
+                        agv_TrayStatus = "EmptyTray",//station.tray_status,
+                        agv_Traytype = station.tray_type,
                     };
                     agvtaskRepository.Add(taskPart, true);
-                    station.location_state = LocationStateEnum.InBusy.ToString();
+                    station.location_state = LocationStateEnum.OutBusy.ToString();
                     stationinfoRepository.Update(station, true);
-                    WriteDBLog.Success("鍒涘缓琛ュ簱鍐呯┖鎵樹换鍔�", $"浠诲姟缂栧彿锛歿taskPart.agv_tasknum}", "PCS");
+                    //WriteDBLog.Success("鍒涘缓绌烘墭浠诲姟", $"浠诲姟缂栧彿锛歿taskPart.agv_tasknum}", "PCS");
                 }
             }
             catch (Exception ex)
             {
-                WriteDBLog.Error("鍒涘缓琛ュ簱鍐呯┖鎵樹换鍔�", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+                //WriteDBLog.Error("鍒涘缓琛ュ簱鍐呯┖鎵樹换鍔�", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
                 //throw;
             }
         }
+        public static void task()
+        {
+            VOLContext context = new VOLContext();
+            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+            Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
+            var tasks = agvtaskRepository.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList();
+            foreach (var task in tasks)
+            {
+                if (task.agv_tasktype == "TaskType_EmptyPallet")
+                {
+                    if (task.agv_toaddress == "")
+                    {
+                        var EmptyStation = stationinfoRepository.Find(x => x.area == "11" && x.stationCode.Contains("A") && x.quantity < 5 && x.enable).OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault();
+                        if (EmptyStation == null) return;
+                        if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) return;
+                        task.agv_toaddress = EmptyStation.stationCode;
+                        task.EndQuantity = EmptyStation.quantity;
+                        task.agv_taskstate = "Create";
+                        EmptyStation.location_state = LocationStateEnum.Busy.ToString();
+                        stationinfoRepository.Update(EmptyStation, true);
+                        agvtaskRepository.Update(task, true);
+                    }
+                }
+            }
+        }
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
index 14b31a9..787ff0d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs"
@@ -29,8 +29,9 @@
             {
                 VOLContext Context = new VOLContext();
                 Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
+
                 Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context);
-                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList();
+                var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList();
                 foreach (var task in tasks)
                 {
                     if (task.agv_tasktype == "TaskType_EmptyPallet")//绌烘墭浠诲姟
@@ -42,9 +43,9 @@
                             if (!Pipeline_client.IsConnected) throw new Exception("涓庨摼鏉℃満杩炴帴瓒呮椂锛�");
                             var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
                             //鎵�1搴撳尯鐨勭┖鎵樹綅
-                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == "Stroge"/*LocationStateEnum.Stroge.ToString()*/ && x.enable)
-                                .OrderBy(x => x.column).OrderBy(x => x.line).FirstOrDefault();
-
+                            var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") /*&& x.location_state == "Stroge"*//*LocationStateEnum.Stroge.ToString()*/ && x.enable).OrderBy(x => x.column).ThenBy(x => x.line).FirstOrDefault();
+                            if (EmptyStation != null)
+                                if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) EmptyStation = null;
                             #region 涓�涓尯鍩熷彧鑳芥湁涓�涓┖鎵樹换鍔�
                             //bool ok = false;
                             //if (EmptyStation != null)
@@ -107,6 +108,26 @@
                             }
                         }
                     }
+                    else if (task.agv_tasktype == "TaskType_OutsourceCarry")//澶栧崗绉诲簱
+                    {
+                        if (task.agv_toaddress == "")
+                        {
+                            var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository);
+                            if (TargetLocation != null)
+                            {
+                                if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue;
+
+                                task.agv_taskstate = "Create";
+                                task.agv_toaddress = TargetLocation.stationCode;
+                                TargetLocation.location_state = LocationStateEnum.OutBusy.ToString();
+                                TargetLocation.stationType = task.agv_materielid;
+                                stationinfoRepository.Update(TargetLocation, true);
+                                agvtaskService.Update(task, true);
+                                WriteDBLog.Success("鏇存柊鍑哄簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS");
+                                return;
+                            }
+                        }
+                    }
                 }
             }
             catch (Exception ex)
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 ef73816..8880cd9 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"
@@ -34,6 +34,7 @@
                 Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                 Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(context);
                 Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
+                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
 
                 var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "閾炬潯鏈�");
                 if (Pipeline_client == null) throw new Exception("閾炬潯鏈鸿皟搴︽湇鍔℃湭寮�鍚紒");
@@ -43,6 +44,9 @@
 
                 foreach (var item in stationinfos)
                 {
+                    //鍒ゅ畾浠诲姟鏄惁宸插垱寤�//濡傚凡瀛樺湪  
+                    if (agvtaskRepository.Find(x => x.agv_fromaddress == item.stationCode).Any())
+                        continue;
 
                     var PalletSignal = Pipeline_client.ReadByOrder<Int16>("R_PalletSignal", item.stationCode);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃�
                     var MaterialSignal = Pipeline_client.ReadByOrder<Int16>("R_MaterialSignal", item.stationCode);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃�
@@ -50,31 +54,38 @@
 
                     //鏍规嵁涓嬫枡鍙g殑缁戝畾淇℃伅鏌ヨ瀵瑰簲宸ュ崟锛屾娴嬫宸ュ崟鏄惁宸插畬鎴�  瀹屾垚鍗冲彲灏嗗叾閫佸叆搴�
 
-                    dt_mes_head mesinfo = mes_HeadRepository.Find(x => x.jobID == item.Number).FirstOrDefault();
-                    if (mesinfo == null)
+                    var work = workinfoRepository.Find(x => x.workOrder == item.Number && x.drawingNo == x.drawingNo && x.heatID == item.heatNumber).FirstOrDefault();
+                    if (work == null)
                     {
-                        item.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�";
+                        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_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);
 
 
-                    //鍒ゅ畾浠诲姟鏄惁宸插垱寤�//濡傚凡瀛樺湪  
-                    if (agvtaskRepository.Find(x => x.agv_fromaddress == item.stationCode).Any())
-                        continue;
+
                     dt_stationinfo TargetLocation = null;
                     string tasktype = "";
-                    if (item.quantity == 5 || CompeletedNum == 0)  //寰幆璇诲彇杞﹁疆鏁颁负5鎴栬�呰鍗曞凡瀹屾垚鏁伴噺鐨勪笅鏂欏彛    鈫掑伐鍗曚汉宸ュ叧闂殑宸ュ崟
+                    if (item.quantity == 5 /*|| CompeletedNum == 0*/)  //寰幆璇诲彇杞﹁疆鏁颁负5鎴栬�呰鍗曞凡瀹屾垚鏁伴噺鐨勪笅鏂欏彛    鈫掑伐鍗曚汉宸ュ叧闂殑宸ュ崟
                     {
 
 
-                        if (mesinfo.quantity <= 50 || item.stationCode.Contains("3"))    //灏忎簬50浠剁洿鎺ュ嚭搴�
+                        if (/*(mesinfo.quantity <= 50 && string.IsNullOrEmpty(mesinfo.area)) ||*/ item.stationCode.Contains("3"))    //灏忎簬50浠剁洿鎺ュ嚭搴�
                         {
                             //todo 瀵绘壘鍙斁璐у鍗忔斁璐у彴
                             tasktype = "TaskType_OutsourceInbound";
@@ -85,7 +96,8 @@
                         {
                             //todo:  璋冪敤WMS鎺ュ彛鍒涘缓浠诲姟
                             tasktype = "TaskType_Inbound";
-                            TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item, CompeletedNum, dt_Geometry_Data == null ? dt_Geometry_Data1.e : dt_Geometry_Data.e);
+                            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)
                         {
@@ -103,8 +115,8 @@
                                 agv_toaddress = TargetLocation.stationCode,
                                 agv_userid = "绯荤粺",
                                 bindSN = item.bindSN,
-                                agv_worktype = Convert.ToInt32(mesinfo.processCode),
-                                agv_materbarcode = mesinfo.materialCode,
+                                agv_worktype = Convert.ToInt32(work.processCode),
+                                agv_materbarcode = work.materialCode,
                                 agv_Traytype = item.tray_type,
                                 jobID = item.Number,
                                 agv_TrayStatus = item.tray_status
@@ -116,6 +128,8 @@
 
                             TargetLocation.location_state = LocationStateEnum.InBusy.ToString();
                             TargetLocation.stationType = agvtask.agv_materielid;
+                            TargetLocation.heatNumber = item.heatNumber;
+                            TargetLocation.Number = agvtask.jobID;
                             stationinfoRepository.Update(TargetLocation, true);
                             WriteDBLog.Success("鍒涘缓鍏ュ簱浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS");
                         }
@@ -142,8 +156,10 @@
             dt_stationinfo TargetLocation = null;
 
             #region 鍚岀被鍨嬫斁涓�琛�
-            var area1 = GetArea(mesinfo.quantity, e);
-            TargetLocation = stationinfoRepository.Find(x => x.stationType == mesinfo.drawingNo && x.area == area1).OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault();
+            //if (area1 == "1")
+            TargetLocation = stationinfoRepository.Find(x => x.stationType == mesinfo.drawingNo).FirstOrDefault();
+
+            //TargetLocation = stationinfoRepository.Find(x => x.stationType == mesinfo.drawingNo && x.area == area1).OrderByDescending(x => x.line).OrderBy(x => x.column).FirstOrDefault();
             if (TargetLocation != null)
             {
                 #region 鍚屼竴琛屽彧鍏佽涓�涓换鍔�
@@ -152,14 +168,33 @@
                 //    return null;
                 #endregion
 
-                #region 鍑哄簱浠诲姟浼樺厛,瀛樺湪鍑哄簱浠诲姟杩欎竴琛屽垯涓嶈兘鍏ュ簱
-                var OutTask = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == area1 && x.location_state == LocationStateEnum.OutBusy.ToString()).Any();
-                if (OutTask) return null;
+                #region 鍑哄簱浠诲姟浼樺厛,瀛樺湪鍑哄簱浠诲姟鍒欎笉鑳藉叆搴�
+                bool OutTask = false;
+                if (TargetLocation.area == "1")
+                {
+                    TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderByDescending(x => x.line).FirstOrDefault();
+                    if (TargetLocation != null)
+                        OutTask = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area && x.enable && x.location_state == LocationStateEnum.OutBusy.ToString()).Any();
+                    if (OutTask)//杩欏垪瀛樺湪鍑哄簱浠诲姟,瀵绘壘涓�鍒楃┖璐т綅
+                        TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.area == TargetLocation.area && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.column).FirstOrDefault();
+                    if (TargetLocation != null) return TargetLocation;
+                }
+                else
+                {
+                    TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.column).FirstOrDefault();
+                    if (TargetLocation != null)
+                        OutTask = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any();
+                    //搴撳唴瀛樺湪鍑哄簱浠诲姟锛岄噸鏂板紑涓�琛屽叆搴�
+                    if (OutTask)
+                        TargetLocation = stationinfoRepository.Find(x => x.column == (TargetLocation.area == "2" ? 1 : 10) && x.area == TargetLocation.area && x.enable && x.location_state == LocationStateEnum.Empty.ToString()).OrderBy(x => x.line).FirstOrDefault();
+                    if (TargetLocation != null) return TargetLocation;
+                }
+
                 #endregion
 
-                TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == area1 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault();
-                if (TargetLocation != null)
-                    return TargetLocation;
+                //TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.column).FirstOrDefault();
+                //if (TargetLocation != null)
+                //    return TargetLocation;
             }
             #endregion
 
@@ -249,15 +284,19 @@
                 stationinfoRepository.Update(stationinfo, true);
                 return null;
             }
+
+            #region 鏌ユ壘搴撳瓨
             dt_inventory inventory = null;
             if (detail.heatID != null)
             {
-                inventory = inventoryRepository.Find(x => /*x.HeatNumber == detail.heatID &&*/ x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).FirstOrDefault();
+                inventory = inventoryRepository.Find(x => /*x.HeatNumber == detail.heatID &&*/ x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
             }
             else
             {
-                inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).FirstOrDefault();
+                inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
             }
+            #endregion
+
 
             #region 鏍规嵁搴撳瓨鏌ユ壘鍙叆搴撶┖璐т綅
             if (inventory != null)
@@ -277,8 +316,9 @@
 
 
 
+            var area1 = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, e) : mesinfo.area;
 
-            if (CompeletedNum <= 15)
+            if (CompeletedNum <= 15 || area1 == "1")
             {
                 TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
             }
@@ -289,17 +329,31 @@
                 //else if (180 < mesinfo.quantity && mesinfo.quantity <= 225 && e < 1100)
                 //    TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == "3" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault();
                 //if (50 < mesinfo.quantity && e > 1100 || TargetLocation == null)
-                var area = GetArea(mesinfo.quantity, e);
+
+                //var area = GetArea(mesinfo.quantity, e);
 
 
-                TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault();
+                TargetLocation = stationinfoRepository.Find(x => x.column == (area1 == "2" ? 1 : 10) && x.area == area1 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).OrderBy(x => x.column).FirstOrDefault();
                 if (TargetLocation == null)
                 {
-                    if (area == "2")
-                        area = "3";
-                    else if (area == "3")
-                        area = "2";
-                    TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault();
+                    if (area1 == "2")
+                        area1 = "3";
+                    else if (area1 == "3")
+                        area1 = "2";
+                    TargetLocation = stationinfoRepository.Find(x => x.column == (area1 == "2" ? 1 : 10) && x.area == area1 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).OrderBy(x => x.column).FirstOrDefault();
+                    if (TargetLocation == null)
+                    {
+                        //TargetLocation = stationinfoRepository.Find(x => x.stationType == mesinfo.drawingNo && x.area == "1").OrderByDescending(x => x.column).FirstOrDefault();
+
+                        //if (TargetLocation != null)
+                        //    TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderByDescending(x => x.line).FirstOrDefault();
+                        //if (TargetLocation == null)
+                        //    TargetLocation = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).OrderByDescending(x => x.line).FirstOrDefault();
+                        if (TargetLocation == null)
+                            TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
+
+                    }
+
                 }
 
                 //if (TargetLocation == null)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
new file mode 100644
index 0000000..6781e0e
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
@@ -0,0 +1,271 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Comm;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_WCS.IRepositories;
+using WIDESEA_WCS.Repositories;
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.Repositories;
+using static System.Collections.Specialized.BitVector32;
+
+namespace WIDESEA_WCS.JobsPart.Common
+{
+    public class GetLocation
+    {
+        private static readonly object GetEmptyLocationobj = new object();
+        /// <summary>
+        /// 鑾峰彇鍙叆搴撶┖璐т綅
+        /// </summary>
+        /// <param name="stationinfoRepository"></param>
+        /// <param name="mesinfo"></param>
+        /// <param name="stationinfo"></param>
+        /// <returns></returns>
+        public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, VV_Mes_Workinfo mesinfo, dt_stationinfo stationinfo)
+        {
+            lock (GetEmptyLocationobj)
+            {
+                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;
+                    //}
+                    #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
+
+                    #endregion
+
+                    dt_stationinfo TargetLocation = null;
+
+                    #region 鏍规嵁搴撳瓨鏌ユ壘鍙叆搴撶┖璐т綅
+                    if (inventory != null)
+                    {
+                        var station = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode);
+                        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();
+                            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 == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.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;
+                            }
+                        }
+                        //if (TargetLocation != null) return TargetLocation;
+                    }
+                    #endregion
+
+                    #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
+                    TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).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();
+                            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
+
+                    #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;
+                    var area = GetArea(mesinfo.quantity, stationinfo.tray_type);
+                    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 && area != "4")
+                    {
+                        if (area == "2")
+                            area = "3";
+                        else if (area == "3")
+                            area = "2";
+                        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)
+                            TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
+                    }
+                    #endregion
+
+                    if (TargetLocation == null) throw new Exception("搴撲綅宸叉弧");
+                    return TargetLocation;
+                }
+                catch (Exception ex)
+                {
+                    throw;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍏ュ簱绌鸿揣浣�
+        /// </summary>
+        /// <param name="stationinfoRepository"></param>
+        /// <param name="mesinfo"></param>
+        /// <param name="stationinfo"></param>
+        /// <param name="CompeletedNum"></param>
+        /// <param name="e"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_mes_head mesinfo, dt_stationinfo stationinfo)
+        {
+            lock (GetEmptyLocationobj)
+            {
+                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;
+                    }
+                    #region 鏌ユ壘搴撳瓨
+                    dt_inventory inventory = null;
+                    if (detail.heatID != null)
+                    {
+                        inventory = inventoryRepository.Find(x => /*x.HeatNumber == detail.heatID &&*/ x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
+                    }
+                    else
+                    {
+                        inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo /*&& x.jobID == mesinfo.jobID*/).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
+                    }
+                    #endregion
+
+                    dt_stationinfo TargetLocation = null;
+
+                    #region 鏍规嵁搴撳瓨鏌ユ壘鍙叆搴撶┖璐т綅
+                    if (inventory != null)
+                    {
+                        var station = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode);
+                        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();
+                            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 == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.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;
+                            }
+                        }
+                        //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)
+                    {
+                        if (area == "2")
+                            area = "3";
+                        else if (area == "3")
+                            area = "2";
+                        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 && area != "4")
+                            TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
+                    }
+                    #endregion
+
+                    if (TargetLocation == null) throw new Exception("搴撲綅宸叉弧");
+                    return TargetLocation;
+                }
+                catch (Exception ex)
+                {
+                    throw;
+                }
+            }
+        }
+        /// <summary>
+        /// 鏍规嵁鎵樼洏绫诲瀷閫夋嫨搴撳尯
+        /// </summary>
+        /// <param name="quantity"></param>
+        /// <param name="tray_type"></param>
+        /// <returns></returns>
+        private static string GetArea(int quantity, string tray_type)
+        {
+            if (tray_type == "SmallTray")
+            {
+                if (quantity <= 180)
+                    return "2";
+                else
+                    return "3";
+            }
+            else
+                return "4";
+        }
+
+        /// <summary>
+        /// 鏍规嵁杞﹁疆澶у皬閫夋嫨搴撳尯
+        /// </summary>
+        /// <param name="quantity"></param>
+        /// <param name="e"></param>
+        /// <returns></returns>
+        private static string GetArea(int quantity, float e)
+        {
+            if (e < 1100)
+            {
+                if (quantity <= 180)
+                    return "2";
+                else
+                    return "3";
+            }
+            else
+                return "4";
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs"
index fefec01..adbf7e7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs"
@@ -82,7 +82,7 @@
                                         agv_fromaddress = stationinfo.stationCode,
                                         agv_id = Guid.NewGuid(),
                                         agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
-                                        agv_grade = 1,
+                                        agv_grade = 2,
                                         agv_createtime = DateTime.Now,
                                         agv_taskstate = "Queue",
                                         agv_materielid = stationinfo.stationType,
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs"
new file mode 100644
index 0000000..5ccda9a
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs"
@@ -0,0 +1,24 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *Repository鎻愪緵鏁版嵁搴撴搷浣滐紝濡傛灉瑕佸鍔犳暟鎹簱鎿嶄綔璇峰湪褰撳墠鐩綍涓婸artial鏂囦欢澶筕V_Mes_WorkinfoRepository缂栧啓浠g爜
+ */
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_Core.Extensions.AutofacManager;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.Repositories
+{
+    public partial class VV_Mes_WorkinfoRepository : RepositoryBase<VV_Mes_Workinfo> , IVV_Mes_WorkinfoRepository
+    {
+    public VV_Mes_WorkinfoRepository(VOLContext dbContext)
+    : base(dbContext)
+    {
+
+    }
+    public static IVV_Mes_WorkinfoRepository Instance
+    {
+      get {  return AutofacContainerModule.GetService<IVV_Mes_WorkinfoRepository>(); } }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..9b168c2
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs"
@@ -0,0 +1,41 @@
+/*
+ *鎵�鏈夊叧浜嶸V_Mes_Workinfo绫荤殑涓氬姟浠g爜搴斿湪姝ゅ缂栧啓
+*鍙娇鐢╮epository.璋冪敤甯哥敤鏂规硶锛岃幏鍙朎F/Dapper绛変俊鎭�
+*濡傛灉闇�瑕佷簨鍔¤浣跨敤repository.DbContextBeginTransaction
+*涔熷彲浣跨敤DBServerProvider.鎵嬪姩鑾峰彇鏁版嵁搴撶浉鍏充俊鎭�
+*鐢ㄦ埛淇℃伅銆佹潈闄愩�佽鑹茬瓑浣跨敤UserContext.Current鎿嶄綔
+*VV_Mes_WorkinfoService瀵瑰銆佸垹銆佹敼鏌ャ�佸鍏ャ�佸鍑恒�佸鏍镐笟鍔′唬鐮佹墿灞曞弬鐓erviceFunFilter
+*/
+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_WMS.IRepositories;
+
+namespace WIDESEA_WMS.Services
+{
+    public partial class VV_Mes_WorkinfoService
+    {
+        private readonly IHttpContextAccessor _httpContextAccessor;
+        private readonly IVV_Mes_WorkinfoRepository _repository;//璁块棶鏁版嵁搴�
+
+        [ActivatorUtilitiesConstructor]
+        public VV_Mes_WorkinfoService(
+            IVV_Mes_WorkinfoRepository dbRepository,
+            IHttpContextAccessor httpContextAccessor
+            )
+        : base(dbRepository)
+        {
+            _httpContextAccessor = httpContextAccessor;
+            _repository = dbRepository;
+            //澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢�
+            //base.Init(dbRepository);
+        }
+  }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs"
index 9fe1556..1c3ae9d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs"
@@ -17,6 +17,9 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.AspNetCore.Http;
 using WIDESEA_WCS.IRepositories;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_WCS.JobsPart.Common;
+using WIDESEA_Core.ManageUser;
 
 namespace WIDESEA_WCS.Services
 {
@@ -37,5 +40,28 @@
             //澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢�
             //base.Init(dbRepository);
         }
-  }
+        public WebResponseContent FinishWorkOrder(SaveModel model)
+        {
+            WebResponseContent content = new WebResponseContent();
+            VOLContext context = new VOLContext();
+            try
+            {
+                string compeletor = UserContext.Current.UserName;
+                foreach (var Key in model.DelKeys)
+                {
+                    var mes_head = _repository.Find(x => x.mes_id.ToString() == Key.ToString()).FirstOrDefault();
+                    if (mes_head != null)
+                    {
+                        AutoUpdateWork.AddHtyMesWork(mes_head, _repository, compeletor, "鎵嬪姩瀹屾垚");
+                    }
+                }
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return content;
+        }
+    }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/VV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/VV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..ce8ec19
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/VV_Mes_WorkinfoService.cs"
@@ -0,0 +1,27 @@
+/*
+ *Author锛歫xx
+ *Contact锛�283591387@qq.com
+ *浠g爜鐢辨鏋剁敓鎴�,姝ゅ浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *鎵�鏈変笟鍔$紪鍐欏叏閮ㄥ簲鍦≒artial鏂囦欢澶逛笅VV_Mes_WorkinfoService涓嶪VV_Mes_WorkinfoService涓紪鍐�
+ */
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.IServices;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Core.Extensions.AutofacManager;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.Services
+{
+    public partial class VV_Mes_WorkinfoService : ServiceBase<VV_Mes_Workinfo, IVV_Mes_WorkinfoRepository>
+    , IVV_Mes_WorkinfoService, IDependency
+    {
+    public VV_Mes_WorkinfoService(IVV_Mes_WorkinfoRepository repository)
+    : base(repository)
+    {
+    Init(repository);
+    }
+    public static IVV_Mes_WorkinfoService Instance
+    {
+      get { return AutofacContainerModule.GetService<IVV_Mes_WorkinfoService>(); } }
+    }
+ }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToAGV/ToAGVServer.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToAGV/ToAGVServer.cs"
index ffc2571..6477621 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToAGV/ToAGVServer.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToAGV/ToAGVServer.cs"
@@ -70,6 +70,8 @@
                 requestin = JsonConvert.DeserializeObject<AGVRequestin>(json);
                 if (requestin.AreaNr < 1 || requestin.AreaNr > 4)
                     throw new Exception("鏈畾涔夌殑鍖哄煙鍙�!");
+                if (MethodName == "EnteriorLeav")
+                    remark = requestin.Type == 1 ? "AGV姝e湪杩涘叆" : "AGV姝e湪绂诲紑";
                 respone = AGVandGantry.GetSetGantry(requestin, MethodName);
             }
             catch (Exception ex)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/ToMes/ToMESController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/ToMes/ToMESController.cs"
index 39f95ba..79c3509 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/ToMes/ToMESController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/ToMes/ToMESController.cs"
@@ -40,7 +40,7 @@
         /// </summary>
         /// <param name="json"></param>
         /// <returns></returns>
-        [HttpPost,Route("AddMes_Info"),AllowAnonymous]
+        [HttpPost, Route("AddMes_Info"), AllowAnonymous]
         public WebResponseContent AddMES_info([FromBody] object json)
         {
             lock (AddMES_infoobj)
@@ -48,5 +48,7 @@
                 return ToMesServer.AddMes_Info(json);
             }
         }
+
+        
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs"
index 02e9d63..d71e0d2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs"
@@ -11,6 +11,8 @@
 using Microsoft.AspNetCore.Http;
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_WCS.IServices;
+using Microsoft.AspNetCore.Authorization;
+using WIDESEA_Core.Utilities;
 
 namespace WIDESEA_WCS.Controllers
 {
@@ -29,5 +31,17 @@
             _service = service;
             _httpContextAccessor = httpContextAccessor;
         }
+
+        /// <summary>
+        /// 鎵嬪姩瀹屾垚宸ュ崟
+        /// </summary>
+        /// <param name="saveModel"></param>
+        /// <returns></returns>
+
+        [HttpPost, Authorize, Route("FinishWorkOrder"), AllowAnonymous]
+        public WebResponseContent FinishWorkOrder([FromBody] SaveModel saveModel)
+        {
+            return Service.FinishWorkOrder(saveModel);
+        }
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/api/http.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/api/http.js"
index 0af90a4..eb0a016 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/api/http.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/api/http.js"
@@ -12,7 +12,7 @@
 let loadingInstance;
 let loadingStatus = false;
 if (process.env.NODE_ENV == 'development') {
-    axios.defaults.baseURL = 'http://127.0.0.1:8098/';
+    axios.defaults.baseURL = 'http://192.168.12.101:8098/';
 }
 else if (process.env.NODE_ENV == 'debug') {
     axios.defaults.baseURL = 'http://192.168.12.101:8098/';
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask.vue"
index d2a25ff..8dccc18 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask.vue"
@@ -48,7 +48,7 @@
                        {field:'agv_toaddress',title:'缁堢偣鍦板潃',type:'string',width:110,align:'left'},
                     //    {field:'agv_code',title:'AGV缂栧彿',type:'string',bind:{ key:'agv_code',data:[]},width:110,require:true,align:'left'},
                        {field:'agv_taskstate',title:'浠诲姟鐘舵��',type:'string',bind:{ key:'Taskstates',data:[]},width:110,require:true,align:'left'},
-                       {field:'jobID',title:'宸ュ崟鍙�',type:'string',width:110,align:'left'},
+                       {field:'jobID',title:'宸ヤ綔浠ゅ彿',type:'string',width:160,align:'left'},
                     //    {field:'agv_materielid',title:'鐗╂枡绫诲瀷',type:'string',width:110,require:true,align:'left'},
                     {field:'agv_materielid',title:'鍥惧彿',type:'string',width:110,require:true,align:'left'},
                        {field:'bindSN',title:'杞﹁疆SN鍙�',type:'string',width:110,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask_hty.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask_hty.vue"
index 8d4b36f..513b593 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask_hty.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/Task/widesea_wms/taskinfo/dt_agvtask_hty.vue"
@@ -43,7 +43,7 @@
                        {field:'agv_materielid',title:'鐗╂枡绫诲瀷',type:'string',width:110,require:true,align:'left'},
                        {field:'agv_fromaddress',title:'璧风偣鍦板潃',type:'string',width:110,align:'left'},
                        {field:'agv_toaddress',title:'缁堢偣鍦板潃',type:'string',width:110,align:'left'},
-                       {field:'jobID',title:'宸ュ崟鍙�',type:'string',width:110,align:'left'},
+                       {field:'jobID',title:'宸ヤ綔浠ゅ彿',type:'string',width:160,align:'left'},
                        {field:'agv_materielid',title:'鍥惧彿',type:'string',width:110,require:true,align:'left'},
                        {field:'bindSN',title:'杞﹁疆SN鍙�',type:'string',width:110,align:'left'},
                        {field:'agv_qty',title:'鏁伴噺',type:'int',width:110,require:true,align:'left'},
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_inventory.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_inventory.vue"
index 047d79c..8a447ac 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_inventory.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_inventory.vue"
@@ -32,16 +32,19 @@
             const editFormFields = ref({});
             const editFormOptions = ref([]);
             const searchFormFields = ref({"SN":"","Name":"","HearthNumber":"","HeatNumber":"","BilletNumber":"","remark":""});
-            const searchFormOptions = ref([[{"title":"杞﹁疆SN鍙�","field":"SN","type":"like"},{"title":"浜у搧鍚嶇О","field":"Name","type":"like"},{"title":"鎻忚堪","field":"remark","type":"like"}],[{"title":"鐔旂偧鐐夊彿","field":"HearthNumber","type":"like"},{"title":"鐐変唬鍙�","field":"HeatNumber","type":"like"},{"title":"閽㈠澂鍙�","field":"BilletNumber","type":"like"}]]);
+            const searchFormOptions = ref([
+                [{"title":"杞﹁疆SN鍙�","field":"SN","type":"like"},{"title":"璐т綅缂栧彿","field":"stationCode","type":"like"},{"title":"浜у搧鍚嶇О","field":"Name","type":"like"}],
+                [{"title":"浜у搧鍥惧彿","field":"FigureNumber","type":"like"},{"title":"鐐変唬鍙�","field":"HeatNumber","type":"like"},{"title":"宸ヤ綔浠ゅ彿","field":"BilletNumber","type":"like"}]]);
             const columns = ref([
-                       {field:'stationCode',title:'璐т綅缂栧彿',type:'string',width:100,align:'left',sort:true},
+                       {field:'stationCode',title:'璐т綅缂栧彿',type:'string',width:120,align:'left',sort:true},
                        {field:'SN',title:'杞﹁疆SN鍙�',type:'string',width:120,align:'left',sort:true},
-                       {field:'Name',title:'浜у搧鍚嶇О',type:'string',width:120,align:'left'},
-                       {field:'FigureNumber',title:'浜у搧鍥惧彿',type:'string',width:120,align:'left'},
+                       {field:'Name',title:'浜у搧鍚嶇О',type:'string',width:120,align:'left',sort:true},
+                       {field:'FigureNumber',title:'浜у搧鍥惧彿',type:'string',width:120,align:'left',sort:true},
+                       {field:'jobID',title:'宸ヤ綔浠ゅ彿',type:'string',width:160,align:'left',sort:true},
                     //    {field:'area',title:'鍖哄煙浠g爜',type:'string',width:80,align:'left'},
-                       {field:'HeatNumber',title:'鐐変唬鍙�',type:'string',width:80,align:'left'},
+                       {field:'HeatNumber',title:'鐐変唬鍙�',type:'string',width:100,align:'left',sort:true},
                        {field:'BilletNumber',title:'閽㈠澂鍙�',type:'int',width:80,align:'left'},
-                       {field:'OnlineTime',title:'鍏ュ簱鏃堕棿',type:'datetime',width:150,align:'left',sort:true},
+                       {field:'OnlineTime',title:'鍏ュ簱鏃堕棿',type:'datetime',width:160,align:'left',sort:true},
                        {field:'Operator',title:'鎿嶄綔浜哄憳',type:'string',width:110,align:'left'},
                        {field:'remark',title:'鎻忚堪',type:'string',width:220,align:'left'},
                        {field:'ID',title:'ID',type:'int',width:110,hidden:true,readonly:true,require:true,align:'left'}]);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue"
index 6f02139..ffbbaa2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue"
@@ -35,7 +35,7 @@
                               [{"dataKey":"location_states","data":[],"title":"璐т綅鐘舵��","field":"location_state","type":"select"}],
                               [{"title":"杞﹁疆SN鍙�","field":"bindSN"}],
                               [{"dataKey":"tray_types","data":[],"title":"鎵樼洏绫诲瀷","field":"tray_type","type":"select"}],
-                              [{"title":"宸ュ崟缂栧彿","field":"Number"}],
+                              [{"title":"宸ヤ綔浠ゅ彿","field":"Number"}],
                               [{"title":"鐐夊彿","field":"heatNumber","type":"text"}],
                               [{"title":"澶囨敞","field":"remark"}]]);
             const searchFormFields = ref({"stationCode":"","stationType":"","area":"","enable":"","location_state":[],"bindSN":""});
@@ -50,12 +50,12 @@
                        {field:'quantity',title:'鏁伴噺',type:'int',width:80,align:'left'},
                        {field:'bindSN',title:'杞﹁疆SN鍙�',type:'string',width:220,align:'left'},
                        {field:'tray_status',title:'鎵樼洏鐘舵��',type:'string',bind:{ key:'tray_status',data:[]},width:80,align:'left'},
-                       {field:'tray_type',title:'鎵樼洏绫诲瀷',type:'string',bind:{ key:'tray_types',data:[]},width:120,align:'left'},
+                       {field:'tray_type',title:'鎵樼洏绫诲瀷',type:'string',bind:{ key:'tray_types',data:[]},width:100,align:'left'},
                     //    {field:'line',title:'琛�',type:'int',width:80,align:'left'},
                     //    {field:'column',title:'鍒�',type:'int',width:80,align:'left'},
-                    // {field:'heatNumber',title:'鐐夊彿',type:'int',width:80,align:'left'},
+                    {field:'heatNumber',title:'鐐夊彿',type:'string',width:80,align:'left'},
                     //    {field:'zj',title:'涓婚敭',type:'int',width:80,hidden:true,require:true,align:'left'},
-                       {field:'Number',title:'宸ュ崟缂栧彿',type:'string',width:220,align:'left'},
+                       {field:'Number',title:'宸ヤ綔浠ゅ彿',type:'string',width:160,align:'left'},
                        {field:'remark',title:'澶囨敞',type:'string',width:220,align:'left'}]);
             const detail = ref({
                 cnName: "#detailCnName",
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
index f43a0e4..2e3dab7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
@@ -15,6 +15,22 @@
         /// <summary>
         /// 绌鸿揣浣�
         /// </summary>
-        Empty
+        Empty,
+        /// <summary>
+        /// 鍗犵敤
+        /// </summary>
+        Busy,
+        /// <summary>
+        /// 鍏ュ簱鍗犵敤
+        /// </summary>
+        InBusy,
+        /// <summary>
+        /// 鍑哄簱鍗犵敤
+        /// </summary>
+        OutBusy,
+        /// <summary>
+        /// 寮傚父
+        /// </summary>
+        Abnormal
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
index 56666b8..3c3ca11 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs"
@@ -53,6 +53,14 @@
         public string materialCode { get; set; }
 
         /// <summary>
+        ///鎶�鏈姸鎬�
+        /// </summary>
+        [Display(Name = "鎶�鏈姸鎬�")]
+        [MaxLength(10)]
+        [Column(TypeName = "nvarchar(10)")]
+        [Editable(true)]
+        public string drawingNoVer { get; set; }
+        /// <summary>
         ///鐔旂偧鐐夊彿
         /// </summary>
         //[Display(Name = "鐔旂偧鐐夊彿")]
@@ -128,7 +136,7 @@
         [Editable(true)]
         public string area { get; set; }
         /// <summary>
-        /// 宸ュ崟缂栧彿
+        /// 宸ュ崟缂栧彿/宸ヤ綔浠ゅ彿
         /// </summary>
         [Display(Name = "宸ュ崟缂栧彿")]
         [Column(TypeName = "nvarchar(40)")]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
index 8c9b9f6..e8934a1 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs"
@@ -85,7 +85,7 @@
         public string agv_taskstate { get; set; }
 
         /// <summary>
-        ///宸ュ崟绫诲瀷/AGV宸ヤ綔绫诲瀷
+        ///宸ュ崟绫诲瀷 (17-鏈哄姞宸� 28-妫�娴嬬嚎 101绉诲簱澶栧崗)
         /// </summary>
         [Display(Name = "AGV宸ヤ綔绫诲瀷")]
         [Column(TypeName = "int")]
@@ -173,7 +173,7 @@
         public string agv_remark { get; set; }
 
         /// <summary>
-        ///浠诲姟绛夌骇  0銆佹殏缂�1銆佹甯�2銆佸姞鎬�
+        ///浠诲姟绛夌骇  0锛氭殏缂�1锛氭甯�2锛氬姞鎬� 3锛氱壒鎬�
         /// </summary>
         [Display(Name = "浠诲姟绛夌骇")]
         [Column(TypeName = "int")]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs"
new file mode 100644
index 0000000..9710d82
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs"
@@ -0,0 +1,164 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *濡傛灉鏁版嵁搴撳瓧娈靛彂鐢熷彉鍖栵紝璇峰湪浠g爜鐢熷櫒閲嶆柊鐢熸垚姝odel
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Entity.SystemModels;
+
+namespace WIDESEA_Entity.DomainModels
+{
+    [Entity(TableCnName = "宸ュ崟瑙嗗浘",TableName = "VV_Mes_Workinfo")]
+    public partial class VV_Mes_Workinfo:BaseEntity
+    {
+        /// <summary>
+       ///宸ュ崟缂栧彿
+       /// </summary>
+       [Display(Name ="jobID")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string jobID { get; set; }
+
+        /// <summary>
+        ///鐐変唬鍙�
+        /// </summary>
+        [Display(Name ="heatID")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string heatID { get; set; }
+
+        /// <summary>
+        ///閽㈠澂鍙�
+        /// </summary>
+        [Display(Name ="billetID")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       public int? billetID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="SN")]
+       [MaxLength(50)]
+       [Column(TypeName="nvarchar(50)")]
+       [Editable(true)]
+       public string SN { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="heatBatchID")]
+       [MaxLength(30)]
+       [Column(TypeName="nvarchar(30)")]
+       [Editable(true)]
+       public string heatBatchID { get; set; }
+
+       /// <summary>
+       ///宸ヤ綔浠ゅ彿
+       /// </summary>
+       [Display(Name ="workOrder")]
+       [MaxLength(50)]
+       [Column(TypeName="nvarchar(50)")]
+       [Editable(true)]
+       public string workOrder { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="reqID")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string reqID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="reqIDLineNo")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string reqIDLineNo { get; set; }
+
+       /// <summary>
+       ///鐗╂枡缂栫爜
+       /// </summary>
+       [Display(Name ="materialCode")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string materialCode { get; set; }
+
+       /// <summary>
+       ///鍥惧彿
+       /// </summary>
+       [Display(Name ="drawingNo")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string drawingNo { get; set; }
+
+       /// <summary>
+       ///鎶�鏈姸鎬�
+       /// </summary>
+       [Display(Name ="drawingNoVer")]
+       [MaxLength(10)]
+       [Column(TypeName="nvarchar(10)")]
+       [Editable(true)]
+       public string drawingNoVer { get; set; }
+
+        /// <summary>
+        ///浜у搧鍚嶇О
+        /// </summary>
+        [Display(Name ="productName")]
+       [MaxLength(40)]
+       [Column(TypeName="nvarchar(40)")]
+       [Editable(true)]
+       public string productName { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="quantity")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       public int? quantity { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Display(Name ="typeID")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string typeID { get; set; }
+
+       /// <summary>
+       ///
+       /// </summary>
+       [Key]
+       [Display(Name ="stackNoRange")]
+       [Column(TypeName="int")]
+       [Editable(true)]
+       [Required(AllowEmptyStrings=false)]
+       public int stackNoRange { get; set; }
+
+        /// <summary>
+        ///宸ュ崟绫诲瀷 (17-鏈哄姞宸� 28-妫�娴嬬嚎 101-绉诲簱澶栧崗)
+        /// </summary>
+        [Display(Name ="processCode")]
+       [MaxLength(20)]
+       [Column(TypeName="nvarchar(20)")]
+       [Editable(true)]
+       public string processCode { get; set; }
+
+       
+    }
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs"
new file mode 100644
index 0000000..c07f48b
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/partial/VV_Mes_Workinfo.cs"
@@ -0,0 +1,21 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *濡傛灉鏁版嵁搴撳瓧娈靛彂鐢熷彉鍖栵紝璇峰湪浠g爜鐢熷櫒閲嶆柊鐢熸垚姝odel
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Entity.SystemModels;
+
+namespace WIDESEA_Entity.DomainModels
+{
+    
+    public partial class VV_Mes_Workinfo
+    {
+        //姝ゅ閰嶇疆瀛楁(瀛楁閰嶇疆瑙佹model鐨勫彟涓�涓猵artial),濡傛灉琛ㄤ腑娌℃湁姝ゅ瓧娈佃鍔犱笂 [NotMapped]灞炴�э紝鍚﹀垯浼氬紓甯�
+    }
+}
\ No newline at end of file
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/MappingConfiguration/ToMES/VV_Mes_WorkinfoMapConfig.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/MappingConfiguration/ToMES/VV_Mes_WorkinfoMapConfig.cs"
new file mode 100644
index 0000000..e399135
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Entity/MappingConfiguration/ToMES/VV_Mes_WorkinfoMapConfig.cs"
@@ -0,0 +1,16 @@
+using WIDESEA_Entity.MappingConfiguration;
+using WIDESEA_Entity.DomainModels;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace WIDESEA_Entity.MappingConfiguration
+{
+    public class VV_Mes_WorkinfoMapConfig : EntityMappingConfiguration<VV_Mes_Workinfo>
+    {
+        public override void Map(EntityTypeBuilder<VV_Mes_Workinfo>
+        builderTable)
+        {
+          //b.Property(x => x.StorageName).HasMaxLength(45);
+        }
+     }
+}
+
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
index 2cd466d..d332a4a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
@@ -34,10 +34,10 @@
                 VOLContext Context = new VOLContext();
                 Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
                 var agv_tasks = agvtaskRepository.Find(x => x.agv_taskstate == "Create" && string.IsNullOrEmpty(x.agv_remark)).OrderByDescending(x => x.agv_grade)
-                        .OrderBy(x => x.agv_createtime).ToList();
+                        .ThenBy(x => x.agv_createtime).ToList();
                 if (agv_tasks.Count < 1)
                     agv_tasks = agvtaskRepository.Find(x => x.agv_taskstate == "Create" && !string.IsNullOrEmpty(x.agv_remark)).OrderByDescending(x => x.agv_grade)
-                        .OrderBy(x => x.agv_createtime).ToList();
+                        .ThenBy(x => x.agv_createtime).ToList();
                 if (agv_tasks.Count > 0)
                 {
                     foreach (var agv_task in agv_tasks)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs"
index b7932b0..cf72c64 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs"
@@ -11,6 +11,7 @@
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_WMS.IRepositories;
 using WIDESEA_WMS.Repositories;
+using static FreeSql.Internal.GlobalFilter;
 
 namespace WIDESEA_WMS.Common
 {
@@ -66,10 +67,6 @@
         /// <param name="task"></param>
         public static void Updateinventory(dt_agvtask task)
         {
-            //string[] bindSNs = task.bindSN.Split(",");
-            //int count = 0;
-            //if (bindSNs.Length > 0)
-            //{
             if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString() || task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())
             {
                 string[] bindSNs = task.bindSN.Split(",");
@@ -83,7 +80,6 @@
                     if (count < 1)
                         throw new Exception("搴撳瓨娓呴櫎澶辫触锛丼N鍙�:" + bindSN);
                 }
-
             }
             else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Inbound.ToString())
             {
@@ -92,26 +88,24 @@
                 List<dt_inventory> inventorys = new List<dt_inventory>();
                 foreach (string bindSN in bindSNs)
                 {
-                    var mes_detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == bindSN).First();
-                    if (mes_detail == null)
-                        throw new Exception("鏈壘鍒板伐鍗曚俊鎭紒");
-                    var mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_detail.jobID).First();
-                    if (mes_head == null)
+                    var mes_Work = freeDB.Select<VV_Mes_Workinfo>().Where(x => x.SN == bindSN && x.processCode == "17").First();
+                    if (mes_Work == null)
                         throw new Exception("鏈壘鍒板伐鍗曚俊鎭紒");
                     var station = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode == task.agv_toaddress).First();
                     dt_inventory inventory = new dt_inventory()
                     {
                         SN = bindSN,
-                        Name = mes_head.productName,
-                        FigureNumber = mes_head.drawingNo,
+                        Name = mes_Work.productName,
+                        FigureNumber = mes_Work.drawingNo,
                         materialCode = task.agv_materbarcode,
-                        HeatNumber = mes_detail.heatID,
-                        BilletNumber = mes_detail.billetID,
+                        HeatNumber = mes_Work.heatID,
+                        drawingNoVer = mes_Work.drawingNoVer,
+                        BilletNumber = mes_Work.billetID,
                         OnlineTime = task.agv_finishedtime,
                         Operator = "admin",
                         stationCode = task.agv_toaddress,
                         area = station.area,
-                        jobID = mes_detail.jobID,
+                        jobID = mes_Work.workOrder,
                         ID = Guid.NewGuid()
                     };
                     inventorys.Add(inventory);
@@ -210,8 +204,8 @@
                     station1.stationType = string.Empty;
                     station1.tray_status = string.Empty;
                     station1.remark = string.Empty;
-                    if (!station1.stationCode.Contains("X") && !station1.stationCode.Contains("S") && !station1.stationCode.Contains("W01001004") && !station1.stationCode.Contains("W01001005"))
-                        station1.tray_type = string.Empty;
+                    //if (!station1.stationCode.Contains("X") && !station1.stationCode.Contains("S") && !station1.stationCode.Contains("W01001004") && !station1.stationCode.Contains("W01001005"))
+                    //    station1.tray_type = string.Empty;
                 }
                 stationinfoRepository.Update(station1, true);
             }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask_Mes.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask_Mes.cs"
index 709dd44..fc4e4b0 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask_Mes.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask_Mes.cs"
@@ -35,7 +35,7 @@
                     throw new Exception("鏃犱换鍔℃暟鎹�");
                 }
 
-                if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString() || task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceOutbound.ToString())
+                if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString() /*|| task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceOutbound.ToString()*/|| task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())
                 {
                     foreach (var item in task.bindSN.Split(","))
                     {
@@ -45,13 +45,13 @@
                     }
                     agvInWarehousePara outWarehousePara = new agvInWarehousePara()
                     {
-                        details = list,
                         JobID = task.jobID,
+                        zoneID = task.agv_fromaddress,
                         processCode = task.agv_worktype.ToString(),
+                        details = list,
                         layerNo = 1,
                         stackID = "1",
                         warehouseName = "Agv搴�",
-                        zoneID = task.agv_fromaddress,
                     };
                     obj = outWarehousePara;
                     ActionName = "agvOutWarehouse";//AGV->MES杞﹁疆鍑哄簱
@@ -67,13 +67,13 @@
                     }
                     agvInWarehousePara inWarehousePara = new agvInWarehousePara()
                     {
-                        details = list,
                         JobID = task.jobID,
+                        zoneID = task.agv_toaddress,
                         processCode = task.agv_worktype.ToString(),
+                        details = list,
                         layerNo = 1,
                         stackID = "1",
                         warehouseName = "Agv搴�",
-                        zoneID = task.agv_toaddress,
                     };
                     obj = inWarehousePara;
                     ActionName = "agvInWarehouse";//AGV->MES杞﹁疆鍏ュ簱
@@ -82,39 +82,51 @@
                 //else if (task.agv_tasktype == "Transfer")  //绉诲簱鍖哄垎  搴撳唴绉诲簱
                 else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Carry.ToString())  //绉诲簱鍖哄垎  搴撳唴绉诲簱
                 {
+                    foreach (var item in task.bindSN.Split(","))
+                    {
+                        detail detail = new detail();
+                        detail.sn = item;
+                        list.Add(detail);
+                    }
                     agvMoveWarehousePara moveWarehousePara = new agvMoveWarehousePara()
                     {
+                        fromZoneID = task.agv_fromaddress,
+                        toZoneID = task.agv_toaddress,
                         details = list,
                         fromLayerNo = "1",
                         fromStackID = "1",
                         fromWarehouseName = "Agv搴�",
-                        fromZoneID = task.agv_fromaddress,
                         toLayerNo = "1",
                         toStackID = "1",
                         toWarehouseName = "Agv搴�",
-                        toZoneID = task.agv_toaddress,
                     };
                     obj = moveWarehousePara;
                     ActionName = "agvMoveWarehouse";//AGV->MES杞﹁疆绉诲簱
                     name = "AGV鍚屾MES杞﹁疆AB搴撶Щ搴�";
                 }
-                else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())// 澶栧崗绉诲簱
+                //else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())// 澶栧崗绉诲簱
+                //{
+                //    var mes_head = FreeDB.Select<dt_mes_head>().Where(x => x.jobID == task.jobID).First();
+                //    agvTransferListPara agvTransferListPara = new agvTransferListPara()
+                //    {
+                //        transferListID = task.agv_tasknum,
+                //        materialCode = mes_head.materialCode,
+                //        details = list,
+                //        drawingNoVer = mes_head.drawingNoVer,
+                //        fromWarehouse = "AGV搴�",
+                //        toWarehouse = "姣涜疆搴�",
+                //        Operator = task.agv_userid,
+                //        updateTime = task.agv_createtime.ToString(),
+                //    };
+                //    obj = agvTransferListPara;
+                //    ActionName = "agvTransferList";
+                //    name = "AGV鍚屾MES杞﹁疆绉诲簱AB搴�->BC搴�";
+                //}
+                else
                 {
-                    var mes_head = FreeDB.Select<dt_mes_head>().Where(x => x.jobID == task.jobID).First();
-                    agvTransferListPara agvTransferListPara = new agvTransferListPara()
-                    {
-                        details = list,
-                        transferListID = task.agv_tasknum,
-                        materialCode = mes_head.materialCode,
-                        drawingNoVer = mes_head.drawingNoVer,
-                        fromWarehouse = "AGV搴�",
-                        toWarehouse = "姣涜疆搴�",
-                        Operator = task.agv_userid,
-                        updateTime = task.agv_createtime.ToString(),
-                    };
-                    obj = agvTransferListPara;
-                    ActionName = "agvTransferList";
-                    name = "AGV鍚屾MES杞﹁疆绉诲簱AB搴�->BC搴�";
+                    requestMes.code = "200";
+                    requestMes.Type = "success";
+                    return requestMes;
                 }
 
                 var postJson = JsonConvert.SerializeObject(obj);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs"
new file mode 100644
index 0000000..be7c61b
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IRepositories/ToMES/IVV_Mes_WorkinfoRepository.cs"
@@ -0,0 +1,18 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *Repository鎻愪緵鏁版嵁搴撴搷浣滐紝濡傛灉瑕佸鍔犳暟鎹簱鎿嶄綔璇峰湪褰撳墠鐩綍涓婸artial鏂囦欢澶笽VV_Mes_WorkinfoRepository缂栧啓鎺ュ彛
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_Core.Extensions.AutofacManager;
+namespace WIDESEA_WMS.IRepositories
+{
+    public partial interface IVV_Mes_WorkinfoRepository : IDependency,IRepository<VV_Mes_Workinfo>
+    {
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/IVV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/IVV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..4211a9e
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/IVV_Mes_WorkinfoService.cs"
@@ -0,0 +1,12 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ */
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.IServices
+{
+    public partial interface IVV_Mes_WorkinfoService : IService<VV_Mes_Workinfo>
+    {
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..a8cedcb
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/IServices/ToMES/Partial/IVV_Mes_WorkinfoService.cs"
@@ -0,0 +1,13 @@
+/*
+*鎵�鏈夊叧浜嶸V_Mes_Workinfo绫荤殑涓氬姟浠g爜鎺ュ彛搴斿湪姝ゅ缂栧啓
+*/
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_Core.Utilities;
+using System.Linq.Expressions;
+namespace WIDESEA_WMS.IServices
+{
+    public partial interface IVV_Mes_WorkinfoService
+    {
+    }
+ }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs"
new file mode 100644
index 0000000..5ccda9a
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Repositories/ToMES/VV_Mes_WorkinfoRepository.cs"
@@ -0,0 +1,24 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *Repository鎻愪緵鏁版嵁搴撴搷浣滐紝濡傛灉瑕佸鍔犳暟鎹簱鎿嶄綔璇峰湪褰撳墠鐩綍涓婸artial鏂囦欢澶筕V_Mes_WorkinfoRepository缂栧啓浠g爜
+ */
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_Core.Extensions.AutofacManager;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.Repositories
+{
+    public partial class VV_Mes_WorkinfoRepository : RepositoryBase<VV_Mes_Workinfo> , IVV_Mes_WorkinfoRepository
+    {
+    public VV_Mes_WorkinfoRepository(VOLContext dbContext)
+    : base(dbContext)
+    {
+
+    }
+    public static IVV_Mes_WorkinfoRepository Instance
+    {
+      get {  return AutofacContainerModule.GetService<IVV_Mes_WorkinfoRepository>(); } }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..9b168c2
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/Partial/VV_Mes_WorkinfoService.cs"
@@ -0,0 +1,41 @@
+/*
+ *鎵�鏈夊叧浜嶸V_Mes_Workinfo绫荤殑涓氬姟浠g爜搴斿湪姝ゅ缂栧啓
+*鍙娇鐢╮epository.璋冪敤甯哥敤鏂规硶锛岃幏鍙朎F/Dapper绛変俊鎭�
+*濡傛灉闇�瑕佷簨鍔¤浣跨敤repository.DbContextBeginTransaction
+*涔熷彲浣跨敤DBServerProvider.鎵嬪姩鑾峰彇鏁版嵁搴撶浉鍏充俊鎭�
+*鐢ㄦ埛淇℃伅銆佹潈闄愩�佽鑹茬瓑浣跨敤UserContext.Current鎿嶄綔
+*VV_Mes_WorkinfoService瀵瑰銆佸垹銆佹敼鏌ャ�佸鍏ャ�佸鍑恒�佸鏍镐笟鍔′唬鐮佹墿灞曞弬鐓erviceFunFilter
+*/
+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_WMS.IRepositories;
+
+namespace WIDESEA_WMS.Services
+{
+    public partial class VV_Mes_WorkinfoService
+    {
+        private readonly IHttpContextAccessor _httpContextAccessor;
+        private readonly IVV_Mes_WorkinfoRepository _repository;//璁块棶鏁版嵁搴�
+
+        [ActivatorUtilitiesConstructor]
+        public VV_Mes_WorkinfoService(
+            IVV_Mes_WorkinfoRepository dbRepository,
+            IHttpContextAccessor httpContextAccessor
+            )
+        : base(dbRepository)
+        {
+            _httpContextAccessor = httpContextAccessor;
+            _repository = dbRepository;
+            //澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢�
+            //base.Init(dbRepository);
+        }
+  }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/VV_Mes_WorkinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/VV_Mes_WorkinfoService.cs"
new file mode 100644
index 0000000..ce8ec19
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/ToMES/VV_Mes_WorkinfoService.cs"
@@ -0,0 +1,27 @@
+/*
+ *Author锛歫xx
+ *Contact锛�283591387@qq.com
+ *浠g爜鐢辨鏋剁敓鎴�,姝ゅ浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *鎵�鏈変笟鍔$紪鍐欏叏閮ㄥ簲鍦≒artial鏂囦欢澶逛笅VV_Mes_WorkinfoService涓嶪VV_Mes_WorkinfoService涓紪鍐�
+ */
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.IServices;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Core.Extensions.AutofacManager;
+using WIDESEA_Entity.DomainModels;
+
+namespace WIDESEA_WMS.Services
+{
+    public partial class VV_Mes_WorkinfoService : ServiceBase<VV_Mes_Workinfo, IVV_Mes_WorkinfoRepository>
+    , IVV_Mes_WorkinfoService, IDependency
+    {
+    public VV_Mes_WorkinfoService(IVV_Mes_WorkinfoRepository repository)
+    : base(repository)
+    {
+    Init(repository);
+    }
+    public static IVV_Mes_WorkinfoService Instance
+    {
+      get { return AutofacContainerModule.GetService<IVV_Mes_WorkinfoService>(); } }
+    }
+ }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToAGV/ToAGVServer.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToAGV/ToAGVServer.cs"
index 0e0b1d0..5ac0d19 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToAGV/ToAGVServer.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToAGV/ToAGVServer.cs"
@@ -80,9 +80,9 @@
                     task.agv_finishedtime = DateTime.Now;
 
                     #region 鍚屾MES鍑哄叆搴撲俊鎭�
-                    //var mes = HandleTask_Mes.UploadMESInfo(task);
-                    //if (mes.code != "200" && mes.Type != "success")
-                    //    throw new Exception(mes.message);
+                    var mes = HandleTask_Mes.UploadMESInfo(task);
+                    if (mes.code != "200" && mes.Type != "success")
+                        throw new Exception(mes.message);
                     #endregion
 
                     HandleTask.Updateinventory(task);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
index dfff658..7bf5815 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
@@ -56,21 +56,34 @@
                     return content.Error("杞﹁疆SN鍙锋湁璇紒璇烽噸鏂版壂鎻忥紒");
                 #endregion
 
-                dt_mes_detail info = null;
-                dt_mes_head mes_head = null;
+                //dt_mes_detail info = null;
+                //dt_mes_head mes_head = null;
+                VV_Mes_Workinfo mes_Work = null;
 
                 int count = 0;  //杞﹁疆鏁伴噺
-                foreach (var item in sn.Split(","))
+                string bindSN = "";
+                List<string> list = new List<string>();
+                foreach (var SN in sn.Split(","))
+                {
+                    if (!string.IsNullOrEmpty(SN))
+                        list.Add(SN);
+                }
+                foreach (var item in list)
                 {
                     if (item != null)
                     {
                         count++;
-                        info = freeDB.Select<dt_mes_detail>().Where(x => x.SN == item).First();
-                        if (info == null)
-                            return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曡鎯咃紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
-                        mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == info.jobID && x.processCode == "28").First();
-                        if (mes_head == null)
+                        bindSN += bindSN == "" ? item : "," + item;
+
+                         mes_Work = freeDB.Select<VV_Mes_Workinfo>().Where(x => x.SN == item && x.processCode == "28").First();
+                        if (mes_Work == null)
                             return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曚俊鎭紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
+                        //info = freeDB.Select<dt_mes_detail>().Where(x => x.SN == item).First();
+                        //if (info == null)
+                        //    return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曡鎯咃紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
+                        //mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == info.jobID && x.processCode == "28").First();
+                        //if (mes_head == null)
+                        //    return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曚俊鎭紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
                     }
                 }
                 VOLContext Context = new VOLContext();
@@ -81,12 +94,12 @@
                 if (!station.enable)
                     return content.Error($"涓嬫枡鍙stationNo}琚鐢紝璇锋牳瀹烇紒");
                 station.quantity = count;
-                station.bindSN = sn;
-                station.stationType = mes_head.drawingNo;
+                station.bindSN = bindSN;
+                station.stationType = mes_Work.drawingNo;
                 station.location_state = "Stroge";
-                station.Number = mes_head.jobID;
-                if (info.heatID != null)
-                    station.heatNumber = info.heatID;
+                station.Number = mes_Work.jobID;
+                if (mes_Work.heatID != null)
+                    station.heatNumber = mes_Work.heatID;
                 station.tray_status = "StrogeTray";
 
                 stationinfoRepository.Update(station, true);
@@ -110,7 +123,7 @@
                     agv_fromaddress = station.stationCode,
                     agv_id = Guid.NewGuid(),
                     agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
-                    agv_grade = 2,
+                    agv_grade = 3,
                     agv_createtime = DateTime.Now,
                     agv_taskstate = "Queue",
                     agv_materielid = station.stationType,
@@ -118,10 +131,10 @@
                     agv_tasktype = "TaskType_OutsourceOutbound",
                     agv_toaddress = "",
                     agv_userid = user,//"绯荤粺",
-                    jobID = mes_head.jobID,
+                    jobID = mes_Work.jobID,
                     bindSN = station.bindSN,
-                    agv_worktype = Convert.ToInt32(mes_head.processCode),
-                    agv_materbarcode = mes_head.materialCode,
+                    agv_worktype = Convert.ToInt32(mes_Work.processCode),
+                    agv_materbarcode = mes_Work.materialCode,
                     agv_Traytype = station.tray_type,
                     agv_TrayStatus = station.tray_status
                 };
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/agvTransferList.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/agvTransferList.cs"
index 7073360..4be7204 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/agvTransferList.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/agvTransferList.cs"
@@ -1,17 +1,23 @@
 锘縰sing Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using System.Xml.Linq;
 using WIDESEA_Comm;
 using WIDESEA_Comm.LogInfo;
 using WIDESEA_Comm.MES_Info;
 using WIDESEA_Comm.MES_Info.Request;
+using WIDESEA_Comm.TaskNo;
 using WIDESEA_Common;
+using WIDESEA_Core.EFDbContext;
 using WIDESEA_Core.ManageUser;
 using WIDESEA_Core.Utilities;
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_Entity.DomainModels.Mes;
 using WIDESEA_WMS.Common;
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.Repositories;
 using static WIDESEA_Comm.MES_Info.BasicSN;
 
 namespace WIDESEA_WMS
@@ -27,24 +33,32 @@
         {
 
             WebResponseContent content = new WebResponseContent();
+            string postJson = "";
+            string mesData = "";
             try
             {
                 string sn = saveModel.MainData["sn"].ToString();
                 string user = saveModel.MainData["creator"].ToString();
-
-                return content.Error($"{user}鏃犳搷浣滄潈闄�!");
+                VOLContext Context = new VOLContext();
+                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
+                Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(Context);
+                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(Context);
+                //return content.Error($"{user}鏃犳搷浣滄潈闄�!");
                 //宸ュ崟鍙风敓鎴�
                 string jobID = "TW" + DateTime.Now.ToString("HH-mm-ss-ff");
 
                 //鏍规嵁搴撳瓨鏌ヨ杞﹁疆淇℃伅
-                dt_inventory inventory = freeDB.Select<dt_inventory>().Where(x => x.SN.Contains(sn)).First();
+                dt_inventory inventory = inventoryRepository.Find(x => x.SN.Contains(sn)).FirstOrDefault();
                 if (inventory == null)
                 {
                     return content.Error($"鏃犳杞﹁疆{sn}SN鍙�,璇锋牳鏌ュ簱瀛樿褰�!");
                 }
-
+                var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
+                if (!station.enable) return content.Error($"搴撲綅{station.stationCode}鏈惎鐢紝璇锋牳瀹烇紒");
+                if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
+                    return content.Error($"搴撲綅{station.stationCode}瀛樺湪AGV浠诲姟锛岃鏍稿疄锛�");
                 List<detail> list = new List<detail>(); //杞﹁疆淇℃伅
-                foreach (var item in inventory.SN.Split(","))
+                foreach (var item in station.bindSN.Split(","))
                 {
                     detail detail = new detail();
                     detail.sn = item;
@@ -54,29 +68,58 @@
                 agvTransferListPara listPara = new agvTransferListPara
                 {
                     details = list,
-                    transferListID = jobID,
+                    transferListID = jobID,// station.Number,
                     toWarehouse = "姣涜疆搴�",
                     fromWarehouse = "AGV搴�",
                     updateTime = DateTime.Now.ToString(),
-                    drawingNoVer = "",
-                    materialCode = "",
+                    drawingNoVer = inventory.drawingNoVer,
+                    materialCode = inventory.materialCode,
                     Operator = user == null ? "admin" : user
                 };
 
-                var postJson = JsonConvert.SerializeObject(listPara);
-                string mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvTransferList");
+                postJson = JsonConvert.SerializeObject(listPara);
+                mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvTransferList");
+                if (mesData.Contains("杩炴帴灏濊瘯澶辫触"))
+                    throw new Exception(mesData);
                 var requestMes = JsonConvert.DeserializeObject<MES_Response>(mesData);
 
                 if (requestMes.code == "200" && requestMes.Type == "success")
                 {
-                    return content.OK("绉诲簱浜ゆ帴鎴愬姛锛�");
+                    dt_agvtask agvtask = new dt_agvtask()
+                    {
+                        agv_fromaddress = station.stationCode,
+                        agv_id = Guid.NewGuid(),
+                        agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
+                        agv_grade = 1,
+                        agv_createtime = DateTime.Now,
+                        agv_taskstate = "Queue",
+                        agv_materielid = station.stationType,
+                        agv_qty = station.quantity,
+                        agv_tasktype = "TaskType_OutsourceCarry",
+                        agv_toaddress = "",
+                        agv_userid = user,//"绯荤粺",
+                        jobID = jobID,// mes_head.jobID,
+                        bindSN = station.bindSN,
+                        agv_worktype = 101, //Convert.ToInt32(mes_head.processCode),
+                        agv_materbarcode = inventory.materialCode,
+                        agv_Traytype = station.tray_type,
+                        agv_TrayStatus = station.tray_status
+                    };
+                    agvtaskRepository.Add(agvtask, true);
+                    station.location_state = LocationStateEnum.OutBusy.ToString();
+                    stationinfoRepository.Update(station, true);
+                    content.OK("涓嬪彂绉诲簱澶栧崗鎴愬姛锛�");
                     //鏃ュ織璁板綍涓婁紶鏁版嵁鎴愬姛
+                    WriteWMSLog.LogAdd("", "鎴愬姛", "MES", "WMS", postJson, mesData, "AB搴撶Щ搴撳鍗�", "agvTransferList", requestMes.message);
                 }
+                else
+                    throw new Exception(requestMes.message);
 
             }
             catch (Exception ex)
             {
                 content.Error(ex.Message);
+                WriteWMSLog.LogAdd("", "澶辫触", "MES", "WMS", postJson, mesData, "AB搴撶Щ搴撳鍗�", "agvTransferList", ex.Message);
             }
             return content;
         }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/Partial/VV_Mes_WorkinfoController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/Partial/VV_Mes_WorkinfoController.cs"
new file mode 100644
index 0000000..7cedbca
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/Partial/VV_Mes_WorkinfoController.cs"
@@ -0,0 +1,33 @@
+/*
+ *鎺ュ彛缂栧啓澶�...
+*濡傛灉鎺ュ彛闇�瑕佸仛Action鐨勬潈闄愰獙璇侊紝璇峰湪Action涓婁娇鐢ㄥ睘鎬�
+*濡�: [ApiActionPermission("VV_Mes_Workinfo",Enums.ActionPermissionOptions.Search)]
+ */
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.AspNetCore.Http;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_WMS.IServices;
+
+namespace WIDESEA_WMS.Controllers
+{
+    public partial class VV_Mes_WorkinfoController
+    {
+        private readonly IVV_Mes_WorkinfoService _service;//璁块棶涓氬姟浠g爜
+        private readonly IHttpContextAccessor _httpContextAccessor;
+
+        [ActivatorUtilitiesConstructor]
+        public VV_Mes_WorkinfoController(
+            IVV_Mes_WorkinfoService service,
+            IHttpContextAccessor httpContextAccessor
+        )
+        : base(service)
+        {
+            _service = service;
+            _httpContextAccessor = httpContextAccessor;
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/VV_Mes_WorkinfoController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/VV_Mes_WorkinfoController.cs"
new file mode 100644
index 0000000..e19844d
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WMS/VV_Mes_WorkinfoController.cs"
@@ -0,0 +1,21 @@
+/*
+ *浠g爜鐢辨鏋剁敓鎴�,浠讳綍鏇存敼閮藉彲鑳藉鑷磋浠g爜鐢熸垚鍣ㄨ鐩�
+ *濡傛灉瑕佸鍔犳柟娉曡鍦ㄥ綋鍓嶇洰褰曚笅Partial鏂囦欢澶筕V_Mes_WorkinfoController缂栧啓
+ */
+using Microsoft.AspNetCore.Mvc;
+using WIDESEA_Core.Controllers.Basic;
+using WIDESEA_Entity.AttributeManager;
+using WIDESEA_WMS.IServices;
+namespace WIDESEA_WMS.Controllers
+{
+    [Route("api/VV_Mes_Workinfo")]
+    [PermissionTable(Name = "VV_Mes_Workinfo")]
+    public partial class VV_Mes_WorkinfoController : ApiBaseController<IVV_Mes_WorkinfoService>
+    {
+        public VV_Mes_WorkinfoController(IVV_Mes_WorkinfoService service)
+        : base(service)
+        {
+        }
+    }
+}
+
diff --git "a/\351\241\271\347\233\256\350\265\204\346\226\231/\345\205\266\344\273\226/\346\234\215\345\212\241\345\231\250\350\264\246\345\217\267\345\257\206\347\240\201.txt" "b/\351\241\271\347\233\256\350\265\204\346\226\231/\345\205\266\344\273\226/\346\234\215\345\212\241\345\231\250\350\264\246\345\217\267\345\257\206\347\240\201.txt"
new file mode 100644
index 0000000..5d97e1e
--- /dev/null
+++ "b/\351\241\271\347\233\256\350\265\204\346\226\231/\345\205\266\344\273\226/\346\234\215\345\212\241\345\231\250\350\264\246\345\217\267\345\257\206\347\240\201.txt"
@@ -0,0 +1,3 @@
+IP锛�192.168.12.101
+鐢ㄦ埛鍚嶏細TZFWQ
+瀵嗙爜锛�123456
\ No newline at end of file

--
Gitblit v1.9.3