王 垚
2022-12-07 ee9f4215d0750a15031bfb89f0f347dadc8c1b70
WebAPI/Controllers/POStockInBillController.cs
@@ -697,6 +697,152 @@
                    }
                }
                //生产补料校验
                if (HBillType == "1254")
                {
                    string[] sArray = sBarCodeNew.Split('@');
                    string HMaterNumber = "";
                    HMaterNumber = sArray[0];
                    Int64 HQty = 0;
                    HQty = ClsPub.isInt(sArray[4]);
                    string HBarchNo = "";
                    HBarchNo = sArray[6];
                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
                    //采购订单号
                    string HPOOrderBillNo = "";
                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
                    Int64 HMaterID = 0;
                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                    DataSet Dss;
                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
                    DataSet Dss1;
                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
                    HTM = HOrgNumber + HMaterID + HBarchNo;
                    DataSet Dss5;
                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
                    if (Dss5.Tables[0].Rows.Count > 0)
                    {
                    }
                    else
                    {
                        string ModName = "85";
                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                        Int64 HSupID = 0;
                        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,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
                                           ") values ("
                                           + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
                                           + ", " + 0 + "," + 0 + ",'','',0"
                                           + ", 0,'',0,0,0,''"
                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
                                           + ",0,0,0"
                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
                    }
                }
                //销售出库校验
                if (HBillType == "1205")
                {
                    string HMaterNumber = "";
                    HMaterNumber = sBarCodeNew.Substring(0, 10);
                    string HSCRQ = "";
                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
                    string HBatchNo = "";
                    HBatchNo = sBarCodeNew.Substring(16, 11);
                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                    Int64 HMaterID = 0;
                    DataSet Dss1;
                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
                    DataSet Dss;
                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
                    HTM = HOrgNumber + HMaterID + HBatchNo;
                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
                    Int64 HQty = 0;
                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
                    DataSet Dss5;
                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
                    if (Dss5.Tables[0].Rows.Count > 0)
                    {
                    }
                    else
                    {
                        string ModName = "85";
                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                        Int64 HSupID = 0;
                        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,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
                                           ") values ("
                                           + "'" + HTM + "','批次条码'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
                                           + ", 0,0,'','',0"
                                           + ", 0,'',0,0,0,''"
                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
                                           + ",0,0,0"
                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
                    }
                }
                //objJsonResult.code = "0";
                //objJsonResult.count = 1;
                //objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
@@ -2199,7 +2345,7 @@
                string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//客户名称
                string sql = string.Empty;
                if (FCusName.Contains("安瑞"))
                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode}' and HBarCodeType ='箱号内条码'";
                    sql = $"select top 1 HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID =(select distinct HSourceInterID from Cg_POInStockBillSub where HInterID ={HInterID}) and HBarCode = '{HBarcode}' and HBarCodeType ='箱号内条码'";
                else
                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
                DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");