yusijie
2024-06-25 62939c858cd060996fda608e194ba20053be3c00
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -5980,6 +5980,177 @@
        {
            try
            {
                ds = oCn.RunProcReturn("select * from Gy_BarCodeBill where HBarcode='" + HBarCode + "'", "Gy_BarCodeBill");
                if (ds.Tables[0].Rows.Count == 0) {
                    DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
                    string sErrMsg = "";
                    oSystemParameter.ShowBill(ref sErrMsg);
                    if (oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔")
                    {
                        if (!dal.GetInfoByNumber(HBarCode))
                        {
                            //条码解析
                            string[] str = HBarCode.Split('@');
                            if (str[0] != "CMR" && str[0] != "SRM")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "条码解析失败,请确认条码是否正确!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            int HOrgIDs = 0;
                            //查询组织
                            DataSet ds = oCn.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + str[1] + "' ", "Xt_ORGANIZATIONS");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "条码解析失败,请确认条码组织是否正确!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                HOrgIDs = int.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());
                            }
                            string HMaterNames = "";
                            string HMaterModels = "";
                            string HMaterIDs = "0";
                            //查询物料
                            ds = oCn.RunProcReturn("select  * from Gy_Material where HNumber='" + str[4] + "' and HUSEORGID=" + HOrgIDs, "Gy_Material");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "条码解析失败,请确认条码物料是否正确!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                HMaterIDs = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                HMaterNames = ds.Tables[0].Rows[0]["HName"].ToString();
                                HMaterModels = ds.Tables[0].Rows[0]["HModel"].ToString();
                            }
                            string HSupIDs = "0";
                            //查询供应商
                            ds = oCn.RunProcReturn("select * from Gy_Supplier where HNumber='" + str[2] + "' and HUSEORGID=" + HOrgIDs, "Gy_Supplier");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                //sErrMsg = "条码解析失败,请确认条码供应商是否正确!";
                                //return null;
                            }
                            else
                            {
                                HSupIDs = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                            string HSourceInterIDs = "0";
                            string HSourceEntryIDs = "0";
                            string HSourceBillNos = "0";
                            string HUnitIDs = "0";
                            //查询采购订单
                            ds = oCn.RunProcReturn(@"select  a.HInterID,b.HEntryID,a.HBillNo,b.HUnitID from Cg_POOrderBillMain a
inner join Cg_POOrderBillSub b on a.HInterID = b.HInterID where HBillNo='" + str[3] + "' and b.HMaterID=" + HMaterIDs, "Cg_POOrderBillMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                //sErrMsg = "条码解析失败,请确认条码采购订单是否正确!";
                                //return null;
                            }
                            else
                            {
                                HSourceInterIDs = ds.Tables[0].Rows[0]["HInterID"].ToString();
                                HSourceEntryIDs = ds.Tables[0].Rows[0]["HEntryID"].ToString();
                                HSourceBillNos = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                                HUnitIDs = ds.Tables[0].Rows[0]["HUnitID"].ToString();
                            }
                            string HInnerBillNos = "";
                            //查询内部采购订单号
                            ds = oCn.RunProcReturn(@" select * from h_v_IF_POInStockList where é‡‡è´­è®¢å•号= '" + str[3] + "' ", "h_v_IF_POInStockList");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                //sErrMsg = "条码解析失败,请确认条码内部采购订单号是否正确!";
                                //return null;
                                HInnerBillNos = str[3];
                            }
                            else
                            {
                                HInnerBillNos = ds.Tables[0].Rows[0]["内部采购订单号"].ToString();
                            }
                            double HQty = double.Parse(str[6]);
                            //日期获取方式
                            string sDate = DateTime.Now.ToString();
                            string HWei = "0";      //尾数
                            string HBarCodeType = "批次条码";
                            Int64 HMaterID = int.Parse(HMaterIDs);
                            Int64 HAuxPropID = 0;
                            Int64 HUnitID = int.Parse(HUnitIDs);
                            double HQty2 = HQty;
                            string HBatchNo2 = str[5];
                            Int64 HSupID = int.Parse(HSupIDs);
                            Int64 HGroupID = 0;
                            int HPrintQty = 0;
                            Int64 HSourceInterID = int.Parse(HSourceInterIDs);
                            Int64 HSourceEntryID = int.Parse(HSourceEntryIDs);
                            string HSourceBillNo = HSourceBillNos;
                            //HSourceBillType = "1102";
                            Int64 HBarcodeNo = 0;       //托号
                            Int64 HBarcodeQtys = 0;     //总托数
                            Int64 HDeptID = 0;
                            //Int64 HWhID = 0;
                            //Int64 HSPID = 0;
                            string HRemark = "条码解析";
                            string HMaterName = HMaterNames;
                            string HMaterModel = HMaterModels;
                            string HPinfan = "";
                            string HMTONo = "";
                            Int64 HCusID = 0;
                            string HCusType = "";
                            DateTime HEndDate = DateTime.Now;
                            string HWorkLineName = "";
                            string HSeOrderBillNo = "";
                            string HInnerBillNo = HInnerBillNos;
                            bool HGiveAwayFlag = false;
                            Int64 HEntryID = 1;
                            Int64 HInterIDs = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
                            int HOrgID = HOrgIDs;
                            string HSourceBillType = "";
                            oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                               ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                                               ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                                               ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                               ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
                                               ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                               ",HGiveAwayFlag " +
                                               ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo" +
                                               ",HProduceDate,HExpiryDate " +
                                               ") values ("
                                               + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                               + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                               + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                               + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + ",0,0,'" + HRemark + "'"
                                               + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
                                               + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterIDs.ToString() + "," + HEntryID.ToString() + ""
                                               + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
                                               + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "','','')");
                        }
                    }
                }
                ds = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MaterToSource " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HBarCode + "','" + HMaker + "'", "h_p_WMS_AddBarCode_MaterToSource");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {