111
cjs
2025-06-23 5ccc957c0e4768336e3272346942e1d5e2f14624
ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/WMSHelper.cs
@@ -164,6 +164,10 @@
            //物料编号:itemCode
            //物料数量:qty
            public string itemCode { get; set; }
            //物料名称
            public string itemName { get; set; }
            //物料规格
            public string itemModel { get; set; }
            //public string itemFeature { get; set; }
            //public string itemState { get; set; }
            //public string ProductionDate { get; set; }
@@ -423,40 +427,35 @@
                        }
                        else
                        {
                            var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom");
                            CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}");
                            if (ItemCode == "time" && time != null)
                            var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("TimeCuo", timeStamp), "TimeCuoInfoComTwo");
                            CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:TimeCuo={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}");
                            var erpItemTableInfo = MongoDBSingleton.Instance.FindOne<ERPItemTable>(Query.EQ("item_code", time.materialCode), "ERPItemTable");
                            CMMLog.Info($"WMSIn-{startBit}:查询条件:item_code={time.materialCode},读出 ERPItemTable 表数据为:{JsonConvert.SerializeObject(erpItemTableInfo)}");
                            if (ItemCode == "time" && time != null && erpItemTableInfo != null)
                            {
                                CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{time.TimeCuo}!");
                                model.data.Add(new ItemData()
                                {
                                    //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定)
                                    //isFold = time.isFold,
                                    //packingMachineNumber = time.packingMachineNumber,
                                    itemCode = time.productModel,
                                    itemCode = erpItemTableInfo.item_spec,
                                    itemName = erpItemTableInfo.item_name,
                                    itemModel = erpItemTableInfo.item_spec,
                                    lotNo = time.lotNo,
                                    machineNo = time.packingMachineNumber1.ToString(),
                                    packageCode = time.bagNumber1.ToString(),
                                    //palletLayers = time.bagNumber1.ToString(),
                                    foldingbag = time.isFold1.ToString(),
                                    //totalWeight = time.totalWeight,
                                    machineNo = time.packingMachineNumber.ToString(),
                                    packageCode = time.bagNumber.ToString(),
                                    foldingbag = time.isFold.ToString(),
                                    timeStamp = int.Parse(time.TimeCuo),
                                    //productType = time.productModel,
                                    //bagNumber = time.bagNumber,
                                    //needWeight = time.needWeight,
                                    realWeight = time.realWeight1,
                                    //batchNumber = time.batchNumber,
                                    //totalCount = time.totalCount,
                                    realWeight = time.realWeight,
                                    productWeight = time.needWeight.ToString(),
                                    oneTrayWeight = time.realWeight.ToString(),
                                    Jm_Item_Code = time.materialCode,
                                    Jm_Item_Name = time.materialName,
                                    Jm_Item_Model = time.productModel,
                                    Jm_Item_Unit = time.measurementUnit,
                                    Jm_Item_Code = erpItemTableInfo.item_code,
                                    Jm_Item_Name = erpItemTableInfo.item_name,
                                    Jm_Item_Model = erpItemTableInfo.item_spec,
                                    Jm_Item_Unit = erpItemTableInfo.item_uom,
                                    Jm_Item_Staff = employee_id
                                });
                            }
                        }
                    }
                    else
                    {
@@ -472,7 +471,9 @@
                            string product = !string.IsNullOrEmpty(info.productType) ? info.productType : erpItemTableInfo.item_spec;
                            model.data.Add(new ItemData()
                            {
                                itemCode = product,
                                itemCode = info.materialCode,
                                itemName = erpItemTableInfo.item_name,
                                itemModel = erpItemTableInfo.item_spec,
                                lotNo = info.lotNo,
                                machineNo = info.machineNo,
                                packageCode = info.packageCode,
@@ -576,11 +577,11 @@
                        {
                            int timeInt = int.Parse(trayCode);
                            var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoCom>(Query.EQ("timeStamp", timeInt), "TimeCuoInfoCom");
                            CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeInt},读出 TimeCuoInfoCom 表数据为:{JsonConvert.SerializeObject(time)}");
                            CMMLog.Info($"WMSInTwo-{startBit}:{ItemCode}:查询条件:timeStamp={timeInt},读出 TimeCuoInfoCom 表数据为:{JsonConvert.SerializeObject(time)}");
                            if (ItemCode == "time" && time != null)
                            {
                                int TimeStamp = string.IsNullOrEmpty(timeStamp) ? time.timeStamp : int.Parse(timeStamp);
                                CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{TimeStamp}!");
                                CMMLog.Info($"WMSInTwo-{startBit}:time获取时间戳数据为:{TimeStamp}!");
                                model.data.Add(new ItemData()
                                {
                                    //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定)
@@ -612,7 +613,7 @@
                                // 非ERP变更流程可以直接删除 TimeCuoInfoCom 表
                                if (ERPService.ERPSwitch01 == "0")
                                {
                                    CMMLog.Info($"WMSIn-{startBit}:查询条件:timeStamp={timeInt},非ERP变更流程直接删除 TimeCuoInfoCom 表!");
                                    CMMLog.Info($"WMSInTwo-{startBit}:查询条件:timeStamp={timeInt},非ERP变更流程直接删除 TimeCuoInfoCom 表!");
                                    MongoDBSingleton.Instance.Remove<TimeCuoInfoCom>(Query.EQ("timeStamp", timeInt), RemoveFlags.Single);
                                }
                            }
@@ -642,41 +643,6 @@
                                });
                            }
                        }
                        else
                        {
                            var time = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.EQ("timeStamp", timeStamp), "TimeCuoInfoCom");
                            CMMLog.Info($"WMSIn-{startBit}:{ItemCode}:查询条件:timeStamp={timeStamp},读出 TimeCuoInfoComTwo 表数据为:{JsonConvert.SerializeObject(time)}");
                            if (ItemCode == "time" && time != null)
                            {
                                CMMLog.Info($"WMSIn-{startBit}:time获取时间戳数据为:{time.TimeCuo}!");
                                model.data.Add(new ItemData()
                                {
                                    //1楼拆盘机调WMS获取入库终点,传输时间戳数据(暂定)
                                    //isFold = time.isFold,
                                    //packingMachineNumber = time.packingMachineNumber,
                                    itemCode = time.productModel,
                                    lotNo = time.lotNo,
                                    machineNo = time.packingMachineNumber1.ToString(),
                                    packageCode = time.bagNumber1.ToString(),
                                    //palletLayers = time.bagNumber1.ToString(),
                                    foldingbag = time.isFold1.ToString(),
                                    //totalWeight = time.totalWeight,
                                    timeStamp = int.Parse(time.TimeCuo),
                                    //productType = time.productModel,
                                    //bagNumber = time.bagNumber,
                                    //needWeight = time.needWeight,
                                    realWeight = time.realWeight1,
                                    //batchNumber = time.batchNumber,
                                    //totalCount = time.totalCount,
                                    Jm_Item_Code = time.materialCode,
                                    Jm_Item_Name = time.materialName,
                                    Jm_Item_Model = time.productModel,
                                    Jm_Item_Unit = time.measurementUnit,
                                    Jm_Item_Staff = employee_id
                                });
                            }
                        }
                    }
                    else
@@ -690,10 +656,11 @@
                            CMMLog.Info($"WMSInTwo-{startBit}:查询条件:item_code={info.materialCode},读出 ERPItemTable 表数据为:{JsonConvert.SerializeObject(erpItemTableInfo)}");
                            model.locationGear = info.secondNg.ToString();
                            model.trayCode = info.trayCode;
                            string product = !string.IsNullOrEmpty(info.productType) ? info.productType : erpItemTableInfo.item_spec;
                            model.data.Add(new ItemData()
                            {
                                itemCode = product,
                                itemCode = erpItemTableInfo.item_spec,
                                itemName = erpItemTableInfo.item_name,
                                itemModel = erpItemTableInfo.item_spec,
                                lotNo = info.lotNo,
                                machineNo = info.machineNo,
                                packageCode = info.packageCode,
@@ -724,14 +691,14 @@
                string reqStr = "物料名=" + ItemCode + ";数量";
                string feedback = "";
                CMMLog.Info($"WMSIn-{startBit}:【调用wms获取入库货位】:发送数据:{JsonConvert.SerializeObject(msgData)},物料条件:ItemCode:{ItemCode},trayCode:{trayCode}");
                CMMLog.Info($"WMSInTwo-{startBit}:【调用wms获取入库货位】:发送数据:{JsonConvert.SerializeObject(msgData)},物料条件:ItemCode:{ItemCode},trayCode:{trayCode}");
                var url = hao.WebUrl + "GlmInSendTask";
                try
                {
                    //hao.WebUrl = "http://192.168.1.199:9001/api/";
                    feedback = helper.WebPost(url, msgData).Replace(@"\", "").Trim();
                    Console.WriteLine(feedback);
                    CMMLog.Info($"WMSIn-{startBit}:【调用wms获取入库货位】:接收数据:" + feedback);
                    CMMLog.Info($"WMSInTwo-{startBit}:【调用wms获取入库货位】:接收数据:" + feedback);
                    if (!string.IsNullOrEmpty(feedback))
                    {
                        //var wmsResponse = JsonConvert.DeserializeObject<WMSResponseModel>(feedback.Substring(1, feedback.Length - 2));
@@ -739,28 +706,28 @@
                        //var res = feedback.Replace("{", "").Replace("}", "").Replace(":", "=").Replace(",", ";").Replace('"', ' ');
                        if (wmsResponse.Success == true)
                        {
                            msg = $"WMSIn-{startBit}:【调用wms获取入库货位】成功!返回结果=" + wmsResponse.Success + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                            msg = $"WMSInTwo-{startBit}:【调用wms获取入库货位】成功!返回结果=" + wmsResponse.Success + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                        }
                        else
                        {
                            string errMsg = wmsResponse.Code + "-" + wmsResponse.Msg;
                            msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                            msg = $"WMSInTwo-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                        }
                        result = wmsResponse.Success;
                    }
                    else
                    {
                        string errMsg = "参数反馈空值";
                        msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                        msg = $"WMSInTwo-{startBit}:【调用wms获取入库货位】失败!错误原因=" + errMsg + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                    }
                }
                catch (Exception e)
                {
                    CMMLog.Error(string.Format($"WMSIn-{startBit}:【调用wms获取入库货位失败】异常{0}", e.Message), e);
                    msg = $"WMSIn-{startBit}:【调用wms获取入库货位】失败!解析返回值出错=" + feedback + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                    CMMLog.Error(string.Format($"WMSInTwo-{startBit}:【调用wms获取入库货位失败】异常{0}", e.Message), e);
                    msg = $"WMSInTwo-{startBit}:【调用wms获取入库货位】失败!解析返回值出错=" + feedback + ";调用WebUrl=" + url + ";输入参数=" + msgData;
                }
            }
            else msg = string.Format($"WMSIn-{startBit}:调用wms失败,ams工作中心没有设置!");
            else msg = string.Format($"WMSInTwo-{startBit}:调用wms失败,ams工作中心没有设置!");
            CMMLog.Info(msg);
            Console.WriteLine(msg);
            return result;