WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -553,7 +553,7 @@
                sub = JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(sSubStr);
                //条码上道工序是否过站
                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + omodel.HBarCode_P + "'," + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + omodel.HBarCode_P + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_S");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "0";
@@ -611,6 +611,8 @@
                    {
                        Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
                        string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
                        string prefix = omodel.HBarCode_P.Substring(0, 10); // 从索引0开始,截取10个字符 判断每个项目的O星圈配件数量
                        //保存生产组装单主表
                        string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
@@ -619,7 +621,21 @@
,'{HBillNo1}','1','{user}',getdate(),{omodel.HProcExchInterID.ToString()},{omodel.HProcExchEntryID.ToString()},'{omodel.HProcExchBillNo.ToString()}'
,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{omodel.HBarCode_P.ToString()}',{omodel.HMaterID},0,'汇报',{omodel.HProdOrgID})";
                        oCN.RunProc(sql);
                        if (prefix == "#0TE911124") {
                            for (int i = 0; i < sub.Count; i++)
                            {
                                //子表存储
                             string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
                            ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
                            ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
                            values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
                            ,'',{sub[i].HMaterID},0,0,0,3
                            ,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') ";
                                oCN.RunProc(sq2);
                            }
                        }
                        else
                        {
                        for (int i = 0; i < sub.Count; i++)
                        {
                            //子表存储
@@ -631,6 +647,8 @@
,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') ";
                            oCN.RunProc(sq2);
                        }
                        }
                    }
                }
@@ -806,6 +824,7 @@
        {
            try
            {
                string str1 = "";
                ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "h_v_Gy_BarCodeBill");
                //判断条码是否存在条码档案
@@ -829,7 +848,7 @@
                    //判断长度是否为29位 无尘车间
                    if (HBarCode.Length == 29)
                    {
                        string str1 = HBarCode.Substring(18, 8);
                        str1 = HBarCode.Substring(18, 8);
                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
@@ -867,10 +886,14 @@
                            return get_HBardBillSave(HProcExchBillNo, HBarCode);
                        }
                    }
                    //判断长度是否为50位  15车间
                    //判断长度是否为50位  15车间 和 O6项目
                    else if (HBarCode.Length == 50)
                    {
                        string str1 = HBarCode.Substring(42, 8);
                        string prefix = HBarCode.Substring(0, 10); // 从索引0开始,截取10个字符
                        if (prefix == "#0TE911124")
                        {
                            str1 = HBarCode.Substring(41, 3);
                            LogService.Write($"条码前缀" + str1);
                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
@@ -891,6 +914,33 @@
                            //条码生成
                            return get_HBardBillSave(HProcExchBillNo, HBarCode);
                        }
                        }
                        else
                        {
                            str1 = HBarCode.Substring(42, 8);
                            LogService.Write($"条码前缀1.1" + str1);
                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
                            if (dataSet.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "[3791-2-016]条码与流转卡不存在对应关系!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                ClsPub.CurUserName = user;
                                //条码生成
                                return get_HBardBillSave(HProcExchBillNo, HBarCode);
                            }
                        }
                    }
                    else
                    {
@@ -901,11 +951,12 @@
                        return objJsonResult;
                    }
                }
                else {
                else
                {
                    //判断长度是否为29位 无尘车间
                    if (HBarCode.Length == 29)
                    {
                        string str1 = HBarCode.Substring(18, 8);
                        str1 = HBarCode.Substring(18, 8);
                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
@@ -931,10 +982,31 @@
                            }
                        }
                    }
                    //判断长度是否为50位  15车间
                    //判断长度是否为50位  15车间  和 O6项目
                    else if (HBarCode.Length == 50)
                    {
                        string str1 = HBarCode.Substring(42, 8);
                        string prefix = HBarCode.Substring(0, 10); // 从索引0开始,截取10个字符
                        if (prefix == "#0TE911124")
                        {
                            str1 = HBarCode.Substring(41, 3);
                            LogService.Write($"条码前缀" + str1);
                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
                            if (dataSet.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "[3791-2-016]条码与流转卡不存在对应关系!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                        else
                        {
                            str1 = HBarCode.Substring(42, 8);
                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 物料代码,o.HNumber 组织代码 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
@@ -949,6 +1021,8 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        }
                    }
                    if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "")
@@ -2327,5 +2401,40 @@
        }
        #endregion
        #region 工序单品过站 查询当前流转卡是否有已有出站单 获取id 单据号
        [Route("Cj_SingleStation/SingleItemTransit_CZD")]
        [HttpGet]
        public object SingleItemTransit_CZD(string sWhere)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn(sWhere, "WindowPrint");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}