WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -414,14 +414,22 @@
                string HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
                oCN.RunProc("delete from  Sc_AssemblyBill_BindSourceTemp where HInterID =" + HInterID + "  and HBillNo_bak='" + HBillNo + "'");
                oCN.RunProc("delete from  Sc_AssemblyBill_BindBarCodeTemp where HInterID =" + HInterID + "  and HBillNo_bak='" + HBillNo + "'");
                for (int i = 0; i < tempList.Count; i++)
                {
                    //临时配件表
                    //临时源单表
                    oCN.RunProc("Insert Into Sc_AssemblyBill_BindSourceTemp   " +
                    "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HSourceEntryID,HMaterID" +
                    ",HQtyMust,HProdOrgID,HSourceBillType,HAuxPropID,HProcID,HQty,HBatchNo,HMTONo,HPlanMode) " +
                    " values(" + HInterID + "," + (i + 1) + ",'" + HBillNo + "','" + tempList[i].HProcExchBillNo + "',"+ tempList[i].HProcExchInterID + "," + tempList[i].HProcExchEntryID +","+ tempList[i].HMaterID+
                    ",'0','" + HOrgID + "','',0,"+ HProcID + ","+ tempList[i].HQty + ",'" + tempList[i].HBatchNo + "','','') ");
                    //临时配件表
                    oCN.RunProc("Insert Into Sc_AssemblyBill_BindBarCodeTemp   " +
                    "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HSourceEntryID,HMaterID" +
                    ",HProdOrgID,HSourceBillType,HAuxPropID,HProcID,HQty,HBatchNo,HBarCode,HMTONo,HPlanMode) " +
                    " values(" + HInterID + "," + (i + 1) + ",'" + HBillNo + "','" + tempList[i].HProcExchBillNo + "'," + tempList[i].HProcExchInterID + "," + tempList[i].HProcExchEntryID + "," + tempList[i].HMaterID +
                    ",'" + HOrgID + "','',0," + HProcID + "," + tempList[i].HQty + ",'"+ tempList[i].HBatchNo + "','" + tempList[i].HBarCode + "','','') ");
                }
                oCN.Commit();
@@ -674,8 +682,26 @@
                oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{omodel.HBarCode_P}', 1, GETDATE(), '', " + HProcExchInterID + ","+ HProcExchEntryID + ", '"+ HProcExchBillNo + "', '', 0, 0)");
                //把条码写入日志里面
                LogService.CustomWriteLog("条码:" + omodel.HBarCode_P + ",工序:"+ HProcID + ",出站时间:" + DateTime.Now, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
                //反写工序出站单的合格数量
                oCN.RunProc("update Sc_StationOutBillMain set HQty+=1  where HProcExchInterID='" + HProcExchInterID + "' and HProcExchEntryID=" + HProcExchEntryID+ " and HInterID=" + HInterID);
                ds = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
                if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0) {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "出站数量超过流转卡数量!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.Commit();
@@ -710,7 +736,7 @@
                {
                    if (HBarCode.Length == 29)
                    {
                        string str1 = HBarCode.Substring(23, 3);
                        string 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
@@ -719,11 +745,27 @@
                        if (dataSet.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "条码与流转卡不存在对应关系!";
                            objJsonResult.data = null;
                            return objJsonResult;
                            str1 = HBarCode.Substring(23, 3);
                            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 = "条码与流转卡不存在对应关系!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                ClsPub.CurUserName = user;
                                //条码生成
                                return get_HBardBillSave(HProcExchBillNo, HBarCode);
                            }
                        }
                        else {
                            ClsPub.CurUserName = user;
@@ -742,7 +784,7 @@
                }
                else {
                   
                    string str1 = HBarCode.Substring(23, 3);
                    string 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
@@ -751,11 +793,21 @@
                    if (dataSet.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "条码与流转卡不存在对应关系!";
                        objJsonResult.data = null;
                        return objJsonResult;
                        str1 = HBarCode.Substring(23, 3);
                        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 = "条码与流转卡不存在对应关系!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "")
@@ -1494,9 +1546,28 @@
//                        }
                        oCN.RunProc("update Gy_BarCodeBill set HStatus='' where HBarCode='" + model.HBarCode + "'");
                        DataSet dataSet = oCN.RunProcReturn($"select top 1 HInterID  from Sc_StationOutBillMain where HProcExchInterID={subLsit[0].HProcExchInterID} and HProcExchEntryID={subLsit[0].HProcExchEntryID} and HBadCount>0", "Sc_StationOutBillMain");
                        if (dataSet.Tables[0].Rows.Count > 0)
                        {
                            string HOutInterID = dataSet.Tables[0].Rows[0][0].ToString();
                            oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1 where HInterID='" + HOutInterID + "'");
                        }
                        else
                        {
                            oCN.RollBack();
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败,当前流转卡当前工序的出站单没有不良数量!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败,无结果!";
@@ -1843,6 +1914,45 @@
        }
        #endregion
        #region 工序单品过站 追溯报表 配件清单查询
        [Route("Sc_AssemblyBill/AssemblyBillAndStationInBillList_SN")]
        [HttpGet]
        public object AssemblyBillAndStationInBillList_SN(string sWhere)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = "exec h_p_Sc_AssemblyBillAndStationInBillList_SN ";
                string sql = sql1 + sWhere;
                ds = oCN.RunProcReturn(sql, "h_p_Sc_AssemblyBillAndStationInBillList_SN");
                //添加列名
                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 = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序单品过站 逆向追溯报表 流转卡查询
        [Route("Cj_SingleStation/Sc_ProcessExchangeBillMainList")]
        [HttpGet]