From 3bbc6b99b1492d12efde3cc92571fe0e91a81e94 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 22 十二月 2025 14:22:45 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js          |   48 --------
 项目代码/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js            |  171 ++++++++++++++++++++++++++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs |   11 +
 项目代码/WIDESEA_WMSClient/config/buttons.js                                  |    9 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs   |    8 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs     |   80 ++++++++++++-
 6 files changed, 270 insertions(+), 57 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
index bb584b5..b3561d6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
@@ -267,6 +267,15 @@
     onClick: function () {
     }
 }
+,{
+    name: "鏁村崟鍑哄簱",
+    // icon: 'el-icon-upload2',
+    class: '',
+    value: 'OrderOut',
+    type: 'primary',
+    onClick: function () {
+    }
+}
 ]
 
 export default buttons
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
index add6a92..5a01af4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/Dt_AllocateOrder.js"
@@ -179,55 +179,7 @@
                     render(vnode, mountNode);
                 }
             },
-      {
-  name: '鍒嗘壒鍏ュ簱',
-  type: 'primary',
-  value: '鍒嗘壒鍏ュ簱',
-  onClick: async function () { 
-    console.log('鍒嗘壒鍏ュ簱鎸夐挳琚偣鍑伙紝寮�濮嬫牎楠�');
-    const selectedRows = this.$refs.table.getSelected();
 
-    // 鏍¢獙1锛氭槸鍚﹂�変腑琛岋紙鑷冲皯閫夋嫨涓�鏉★級
-    if (selectedRows.length === 0) {
-      console.log('鏍¢獙涓嶉�氳繃锛氭湭閫変腑浠讳綍鍗曟嵁');
-      ElMessage.warning('璇烽�夋嫨鑷冲皯涓�鏉″崟鎹�');
-      return;
-    }
-
-    // 鏀堕泦鎵�鏈夐�変腑鍗曟嵁鐨勭紪鍙凤紙杩囨护鏃犲崟鎹彿鐨勫紓甯歌锛�
-    const inboundOrderNos = selectedRows
-      .filter(row => row.inboundOrderNo)
-      .map(row => row.inboundOrderNo);
-
-    // 鏍¢獙2锛氭槸鍚︽湁鏈夋晥鍗曟嵁鍙�
-    if (inboundOrderNos.length === 0) {
-      console.log('鏍¢獙涓嶉�氳繃锛氶�変腑鍗曟嵁鏃犳湁鏁堢紪鍙�');
-      ElMessage.warning('閫変腑鐨勫崟鎹腑鏃犳湁鏁堢紪鍙凤紝璇烽噸鏂伴�夋嫨');
-      return;
-    }
-
-    try {
-      console.log('鍙戣捣鍒嗘壒鍏ュ簱璇锋眰锛屽弬鏁帮細', { inboundOrderNos});
-      const response = await http.post('/api/InboundOrder/BatchOrderFeedbackToMes', {
-        orderNos: inboundOrderNos, 
-        inout:1
-      });
-
-      const { status, message, data } = response;
-      if (status) {
-        console.log('鍒嗘壒鍏ュ簱鎴愬姛锛屽悗绔繑鍥烇細', data);
-        ElMessage.success(`鍒嗘壒鍏ュ簱鎴愬姛锛佸叡澶勭悊${inboundOrderNos.length}鏉″崟鎹甡);
-        this.refresh(); // 鍏ュ簱鎴愬姛鍚庡埛鏂板垪琛紙澶嶇敤鍘熸湁閫昏緫锛�
-      } else {
-        console.log('鍒嗘壒鍏ュ簱澶辫触锛屽悗绔彁绀猴細', message);
-        ElMessage.error(message || data?.message || '鍒嗘壒鍏ュ簱澶辫触');
-      }
-    } catch (error) {
-      console.error('鍒嗘壒鍏ュ簱璇锋眰寮傚父锛�', error);
-      ElMessage.error('缃戠粶寮傚父鎴栨帴鍙i敊璇紝璇风◢鍚庨噸璇�');
-    }
-  }
-},
      {
   name: '绌烘墭鐩樺叆搴�',
   type: 'primary',
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
index 5db5148..be51ac6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
@@ -376,6 +376,177 @@
         }
       }
 
+      let OrderOutBtn = this.buttons.find(x => x.value == 'OrderOut');
+if (OrderOutBtn) {
+  // 1. 鏀逛负绠ご鍑芥暟锛岀‘淇漷his鎸囧悜Vue缁勪欢瀹炰緥锛堝師鏅�氬嚱鏁皌his鎸囧悜鎸夐挳鏈韩锛�
+  OrderOutBtn.onClick = async () => {
+    // 鐜板湪this鏄疺ue缁勪欢瀹炰緥锛岃兘姝g‘鑾峰彇$refs
+    let rows = this.$refs.table.getSelected();
+    if (rows.length == 0) return this.$error("璇烽�夋嫨鏁版嵁!");
+    if (rows.length > 1) return this.$error("璇烽�夋嫨涓�鏉℃暟鎹�!");
+    
+    // 纭繚閫変腑琛屾湁id锛堟牴鎹疄闄呰〃鏍兼暟鎹瓧娈佃皟鏁达紝姣斿rows[0].detailId绛夛級
+    const selectedId = rows[0].id || rows[0].detailId;
+    if (!selectedId) return this.$error("閫変腑鏁版嵁缂哄皯蹇呰ID瀛楁!");
+
+    const platformOptions = [
+      { label: "绔欏彴2", value: "2-1" },
+      { label: "绔欏彴3", value: "3-1" },
+    ];
+    const mountNode = document.createElement("div");
+    document.body.appendChild(mountNode);
+
+    const formData = reactive({
+      selectedPlatform: platformOptions[0].value,
+    });
+
+    const vnode = createVNode(
+      ElDialog,
+      {
+        title: "鍑哄簱鎿嶄綔 - 閫夋嫨鍑哄簱绔欏彴",
+        width: "500px",
+        modelValue: true,
+        appendToBody: true,
+        "onUpdate:modelValue": (isVisible) => {
+          if (!isVisible) {
+            render(null, mountNode);
+            document.body.removeChild(mountNode);
+          }
+        },
+        style: {
+          padding: "20px 0",
+          borderRadius: "8px",
+        },
+      },
+      {
+        default: () =>
+          h(
+            ElForm,
+            {
+              model: formData,
+              rules: {
+                selectedPlatform: [
+                  { required: true, message: "璇烽�夋嫨鍑哄簱绔欏彴", trigger: "change" },
+                ],
+              },
+              ref: "outboundForm", // 琛ㄥ崟ref
+              labelWidth: "100px",
+              style: {
+                padding: "0 30px",
+              },
+            },
+            [
+              h(ElFormItem, {
+                label: "鍑哄簱绔欏彴",
+                prop: "selectedPlatform",
+                style: {
+                  marginBottom: "24px",
+                },
+              }, [
+                h(ElSelect, {
+                  placeholder: "璇烽�夋嫨鍑哄簱绔欏彴锛�3-12锛�",
+                  modelValue: formData.selectedPlatform,
+                  "onUpdate:modelValue": (val) => {
+                    formData.selectedPlatform = val;
+                  },
+                  style: {
+                    width: "100%",
+                    height: "40px",
+                    borderRadius: "4px",
+                    borderColor: "#dcdfe6",
+                  },
+                }, platformOptions.map((platform) =>
+                  h(ElOption, { label: platform.label, value: platform.value })
+                )),
+              ]),
+              h("div", {
+                style: {
+                  textAlign: "right",
+                  marginTop: "8px",
+                  paddingRight: "4px",
+                },
+              }, [
+                h(ElButton, {
+                  type: "text",
+                  onClick: () => {
+                    render(null, mountNode);
+                    document.body.removeChild(mountNode);
+                    ElMessage.info("鍙栨秷鍑哄簱鎿嶄綔");
+                  },
+                  style: {
+                    marginRight: "8px",
+                    color: "#606266",
+                  },
+                }, "鍙栨秷"),
+                h(ElButton, {
+                  type: "primary",
+                  onClick: async () => {
+                    // 2. 纭繚琛ㄥ崟ref宸叉寕杞斤紙鐢╪extTick閬垮厤鑾峰彇涓嶅埌锛�
+                    await this.$nextTick();
+                    const formRef = vnode.component.refs.outboundForm;
+                    
+                    if (!formRef) {
+                      ElMessage.error("琛ㄥ崟鍒濆鍖栧け璐ワ紝璇烽噸璇�");
+                      return;
+                    }
+
+                    try {
+                      await formRef.validate();
+                    } catch (err) {
+                      return;
+                    }
+                    var param = rows[0].orderNo;
+                    const requestParams = {
+                      detailIds: [],
+                      outboundTargetLocation: formData.selectedPlatform,
+                      outboundQuantity: 1,
+                      operator: this.currentOperator || "admin", 
+                      orderNo: param,
+                    };
+
+                    try {
+
+                      const x = await this.http.post(
+                        "api/Outbound/ProcessPickingOutbound",
+                        requestParams,
+                        "鏁版嵁澶勭悊涓�"
+                      );
+
+                      if (!x.status) {
+                        ElMessage.error(x.message || "鎿嶄綔澶辫触");
+                        return;
+                      }
+
+                      ElMessage.success("鎿嶄綔鎴愬姛");
+                      this.showDetialBox = false;
+                      this.$emit("parentCall", ($vue) => {
+                        $vue.getData();
+                      });
+                    } catch (error) {
+                      // 5. 鎵撳紑閿欒鎹曡幏锛屾柟渚胯皟璇�
+                      console.error("鍑哄簱鎺ュ彛璇锋眰澶辫触锛�", error);
+                      ElMessage.error("璇锋眰澶辫触锛岃绋嶅悗閲嶈瘯");
+                    } finally {
+                      // 鏃犺鎴愬姛澶辫触锛岄兘鍏抽棴寮圭獥
+                      render(null, mountNode);
+                      document.body.removeChild(mountNode);
+                    }
+                  },
+                  style: {
+                    borderRadius: "4px",
+                    padding: "8px 20px",
+                  },
+                }, "纭畾鍑哄簱"),
+              ]),
+            ]),
+      }
+    );
+
+    vnode.appContext = this.$.appContext;
+    render(vnode, mountNode);
+  };
+}
+
     },
     onInited() {
       //妗嗘灦鍒濆鍖栭厤缃悗
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
index a48de1e..b295a20 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
@@ -423,7 +423,13 @@
                     if (response != null && response.IsSuccess)
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
-                        .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+                        .Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
+                    }
+                    else
+                    {
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
+                         .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+                        return content.Error("鍥炰紶MES澶辫触");
                     }
                 }
                 else
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index be08ce1..89c656a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -1107,7 +1107,11 @@
                     {
                         UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
 
-                        _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+                        if(outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+                        {
+                            _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+                        }
+                        
                     }
                 }
                 catch (Exception ex)
@@ -1495,7 +1499,10 @@
                     {
                         UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
 
-                        _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+                        if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+                        {
+                            _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+                        }
                     }
                 }
                 catch (Exception ex)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 9725404..ac4b232 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -744,13 +744,15 @@
                 }
                 Dt_OutboundOrder outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x=>x.Details).First();
 
-                if(outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+                ///鍥炶皟MES
+                HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
+                string reqCode = Guid.NewGuid().ToString();
+                string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                string requestData = string.Empty;
+                List<string> lineNos = new List<string>();
+                if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
                 {
-                    HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
-                    string reqCode = Guid.NewGuid().ToString();
-                    string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-                    string requestData = string.Empty;
-                    List<string> lineNos = new List<string>();
+                    
                     Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo);
                     if (allocateOrder == null)
                     {
@@ -773,6 +775,72 @@
                     httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, requestData);
                     httpResponseResult.ApiUrl = apiUrl;
                 }
+                bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data.Code == "200";
+                string message = "鎴愬姛";
+                if (!isSuccess)
+                {
+                    if (!httpResponseResult.IsSuccess)
+                    {
+                        message = $"MES鎺ュ彛杩斿洖閿欒锛孒TTP浠g爜锛歿httpResponseResult.StatusCode}锛屼俊鎭細{httpResponseResult.ErrorMessage}";
+                    }
+                    else if (httpResponseResult?.Data?.Code != "200")
+                    {
+                        message = $"璋冪敤MES鎺ュ彛澶辫触锛屼唬鐮侊細{httpResponseResult?.Data?.Code}锛屼俊鎭細{httpResponseResult?.Data?.Message}";
+                    }
+                }
+
+                Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord()
+                {
+                    ApiUrl = httpResponseResult.ApiUrl,
+                    InterfaceType = outboundOrder.OrderType == 0 ? 1 : 3,
+                    OrderId = outboundOrder.Id,
+                    OrderNo = outboundOrder.OrderNo,
+                    RequestCode = reqCode,
+                    RequestData = requestData,
+                    FailureReason = message,
+                    LastReturnTime = DateTime.Now,
+                    HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(),
+                    ResponseData = httpResponseResult.Content,
+                    ReturnType = 0,
+                    ReturnCount = 1,
+                    ReturnStatus = isSuccess ? 1 : 2,
+                    SuccessTime = isSuccess ? DateTime.Now : null
+                };
+
+                _unitOfWorkManage.BeginTran();
+                _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand();
+
+                List<Dt_OutboundOrderDetail> outboundOrderDetails = outboundOrder.Details.Where(x => lineNos.Contains(x.lineNo)).ToList();
+                outboundOrderDetails.ForEach(x =>
+                {
+                    if (x.OverOutQuantity == x.OrderQuantity - x.MoveQty)
+                    {
+                        x.ReturnToMESStatus = isSuccess ? 1 : 2;
+                    }
+                    else
+                    {
+                        x.ReturnToMESStatus = isSuccess ? 3 : 4;
+                    }
+                    x.CurrentDeliveryQty = 0;
+                    x.ReturnJsonData = "";
+                });
+
+                mesReturnRecord.ReturnType = outboundOrder.Details.Count == outboundOrderDetails.Count ? 1 : 2;
+
+                if (outboundOrder.Details.Count == outboundOrderDetails.Count && outboundOrderDetails.All(x => x.ReturnToMESStatus == 1 || x.ReturnToMESStatus == 2))
+                {
+                    outboundOrder.ReturnToMESStatus = isSuccess ? 1 : 2;
+                }
+                else
+                {
+                    outboundOrder.ReturnToMESStatus = isSuccess ? 3 : 4;
+                }
+
+                _outboundOrderService.Db.Updateable(outboundOrderDetails).ExecuteCommand();
+                _outboundOrderService.UpdateData(outboundOrder);
+
+                _unitOfWorkManage.CommitTran();
+
                 try
                 {
                     _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);

--
Gitblit v1.9.3