yusijie
9 天以前 04b4d4d975858a0d5e207b9df9f3bb46cc6c14fd
WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -2436,5 +2436,1018 @@
            }
        }
        #endregion
        #region 小卫单品过站接口
        #region  工序单品过站 扫条码码校验返回信息(只用于验证批次是否入库)
        [Route("Cj_SingleStation/checkHBarCode_Batch")]
        [HttpGet]
        public object checkHBarCode_Batch(string HBarCode,string user, int HOrgID)
        {
            try
            {
                ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "h_v_Gy_BarCodeBill");
                //判断条码是否存在条码档案
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "[0000-1-037]校验成功";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-010]没有返回任何记录!当前批次码无入库信息请检查是否扫错";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-010]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  工序单品过站 扫SN码出站保存(保存到出站汇报里(无关键件绑定))
        [Route("Cj_SingleStation/AddStationOutBillList")]
        [HttpPost]
        public object AddStationOutBillList([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg = _value.ToString();
                string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string sMainStr = sArray[0].ToString();//主表信息包含工序,班组,批次等信息
                string barCode_SN = sArray[1].ToString();//扫描的SN码镭雕码产品信息
                string user = sArray[2].ToString();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-038]无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                string sExeReturnInfo = "";
                StationBill omodel = new StationBill();
                omodel = JsonConvert.DeserializeObject<StationBill>(sMainStr);
                //判断是否有对应流转卡信息并获取
                ds = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_ProcessExchangeBillList");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //将流转卡信息写入
                    omodel.HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
                    omodel.HProcExchInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString());
                    omodel.HProcExchEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString());
                    omodel.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HMainMaterID"].ToString());
                    omodel.HCenterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCenterID"].ToString());
                    omodel.HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
                    omodel.HICMOInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOInterID"].ToString());
                    omodel.HICMOEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString());
                    omodel.HICMOQty = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOQty"].ToString());
                    omodel.HProcNo = ds.Tables[0].Rows[0]["HProcNo"].ToString();
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-2-019]]当前SN码和工序无法找到对应流转卡请检查是否输入选择错误";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //条码上道工序是否过站
                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_XW");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-045]查无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-051]" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //判断条码是否已经出站
                //ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 产品条码='" + barCode_SN + "' and HProcExchInterID=" + omodel.HProcExchInterID + " and HProcExchEntryID=" + omodel.HProcExchEntryID + " and HProcID=" + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
                //if (ds.Tables[0].Rows.Count > 0)
                //{
                //    oCN.RollBack();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "[0000-2-039]条码:" + barCode_SN + ",已出站!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                long HMainInterID = 0;
                string BillType = "3791";
                string HBillSubType = "3791";
                long HInterID = omodel.HInterID;//递入type得到的单据ID
                string HBillNo = omodel.HBillNo;//递入type得到的单据号
                int HBillStatus = 1;
                string HMaker = user;//制单人
                string HMouldNum = omodel.HMouldNum;//模穴号
                int HYear = DateTime.Now.Year;
                double HPeriod = DateTime.Now.Month;
                string HRemark = omodel.HRemark;//备注
                string HSourceName = omodel.HSourceName;//生产资源名称
                double HPieceQty = omodel.HPieceQty;//进站PCS数
                double HWasterQty = 0;//报废数量
                double HPlanPieceQty = 0;//进站PNL数
                double HBadPNL = 0;//报废PNL数
                long HICMOInterID = omodel.HICMOInterID;//任务单ID
                long HICMOEntryID = omodel.HICMOEntryID;//任务单ID
                string HICMOBillNo = omodel.HICMOBillNo;//任务单
                int HProcPlanInterID = 0;
                int HProcPlanEntryID = 0;
                string HProcPlanBillNo = "";
                long HProcExchInterID = omodel.HProcExchInterID;
                long HProcExchEntryID = omodel.HProcExchEntryID;
                string HProcExchBillNo = omodel.HProcExchBillNo;//流转卡
                long HMaterID = omodel.HMaterID;//产品ID
                long HProcID = omodel.HProcID;//当前工序ID
                double HICMOQty = omodel.HICMOQty;//任务单数量
                double HPlanQty = omodel.HICMOQty;//移交PNL数
                DateTime HStationOutTime = DateTime.Now;//汇报时间
                long HSourceID = omodel.HSourceID;//生产资源ID
                long HPayProcID = 0;//核算工序ID
                long HGroupID = omodel.HGroupID;//班组ID
                long HDeptID = omodel.HDeptID;
                long HEmpID = omodel.HEmpID;//操作员ID
                long HEmpID2 = omodel.HEmpID2;////操作员2ID
                string HBarCode = barCode_SN;//条形码
                string HAddr = "";
                string HBarCodeMaker = "";
                long HSourceID2 = 0;//生产资源2ID
                long HSourceID3 = 0;//生产资源3ID
                long HSourceID4 = 0;//生产资源4ID
                long HSourceID5 = 0;//生产资源5ID
                long HSupID = 0;
                double HQty = omodel.HQty;//合格数量
                double HPrice = 0;
                double HMoney = 0;
                double HBadCount = omodel.HBadCount;//不良数量
                long HCenterID = omodel.HCenterID;//工作中心ID
                string HProcNo = omodel.HProcNo;//流水号
                string HOrderProcNO = omodel.HOrderProcNO;//订单跟踪号
                string HSourceNameList = omodel.HSourceNameList;//设备清单
                long HMainSourceInterID = omodel.HProcExchInterID;//递入type得到的单据ID
                string HMainSourceBillNo = omodel.HProcExchBillNo;//递入type得到的单据号
                string HMainSourceBillType = "3772";
                bool HLastSubProc = omodel.HLastSubProc;//转下工序
                long HEmpID3 = 0;//操作员3ID
                long HEmpID4 = 0;//操作员4ID
                long HEmpID5 = 0;//操作员5ID
                double HDSQty = 0;//折弯刀数
                double HChongQty = 0;//NCT冲次数
                double HPriceRate = 0;//系数
                double HWorkTimes = 0;//工时
                long HQCCheckID = omodel.HEmpID;//检验员ID
                long HPRDOrgID = omodel.HPRDOrgID;//组织ID
                double HmaterOutqty = 0;//白坯发布
                double HProcPriceRate = 0;//工价系数
                int HTemporaryAreaID = 0;//暂放区
                int HShiftsID = 0;
                string HBatchNo = omodel.HBatchNo;
                double HWeight = omodel.HWeight;
                //获取当前班次
                //DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HDeptID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
                //if (set.Tables[0].Rows.Count > 0)
                //{
                //    HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
                //}
                //判断当天当前的流转卡是否有出站单
                HInterID = DBUtility.ClsPub.CreateBillID("3791", ref sExeReturnInfo);//递入type得到的单据ID
                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3791", ref sExeReturnInfo, true);//递入type得到的单据号
                //主表插入
                oCN.RunProc("Insert Into Sc_StationOutBillMain" +
                "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
                ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
                ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
                ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
                ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
                ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
                ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
                ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
                    ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
                ") " +
                " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
                "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
                "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 +
                "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
                "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
                "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HShiftsID + ") ");
                ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + omodel.HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
                oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HBatchNo,HWeight)
                    values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{barCode_SN}', 1, GETDATE(), '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + $"', '', 0, 0,'{HBatchNo}',{HWeight})");
                //把条码写入日志里面
                LogService.CustomWriteLog("条码:" + barCode_SN + ",工序:" + 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);
                //=========================保存后控制
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_SingleStationOutBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + $@"',{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{barCode_SN}','{user}' ", "h_p_Sc_SingleStationOutBill_AfterSaveCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-016]保存后控制判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-051]保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //============================
                //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 = "[3791-2-028]出站数量超过流转卡数量!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-050]保存成功!";
                objJsonResult.data = HInterID;//返回出站汇报单id
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-051]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 返回历史出战汇报单信息(即历史过站清单)
        [Route("Cj_SingleStation/SingleStationOutBillList")]
        [HttpGet]
        public object get_Display(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-068]出站单无查询权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1" + sWhere + "order by hmainid desc", "h_v_Sc_SingleStationOutBillList");
                }
                else
                {
                    string sql1 = "select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + "  order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_SingleStationOutBillList");
                }
                //添加列名
                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.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                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
        #region  工序单品过站 SN镭雕码查询关键件清单
        [Route("Cj_SingleStation/HBardCodeBomList_XW")]
        [HttpGet]
        public object HBardCodeBomList_XW(string HBillNo,string HBarCode,int HProcID,int HOrgID, string user)
        {
            try
            {
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-068]无查询权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //判断所扫条码是否存在条码档案当中
                ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该条码不存在:" + HBarCode;
                    objJsonResult.data = "";
                    return objJsonResult;
                }
                //条码档案中已有本次扫描的条码,匹配用料清单(扫码数据写入临时表)
                ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomMatch_XW '" + HBillNo + "','" + HBarCode + "','" + HProcID + "'," + HOrgID, "h_p_Gy_BarCodeBillBomList_XW");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = "";
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有查询到数据";
                    objJsonResult.data = "";
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-010]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序单品过站 关键件绑定配件信息临时存储
        [Route("Cj_SingleStation/BarCodeBillBomMatch_XW")]
        [HttpGet]
        public object PartsBardCode_JX(string HBillNo,string HBarCode, string HBarCode_P, int HProcID, string user, int HOrgID)
        {
            try
            {
                //判断所扫条码是否存在条码档案当中
                ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    //条码档案中没有本次扫描的条码,则根据规则解析生成条码
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该条码不存在:" + HBarCode;
                    objJsonResult.data = "";
                    return objJsonResult;
                }
                //条码档案中已有本次扫描的条码,查询配件信息(扫描条码信息写入临时表)
                ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomBind_XW '" + HBillNo + "','" + HBarCode + "','" + HBarCode_P + "','" + HProcID + "','" + HOrgID + "'", "h_p_Gy_BarCodeBillBomBind_XW");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = "";
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "";
                    objJsonResult.data = "没有查询到数据";
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "ERROR!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  工序单品过站 扫SN码出站保存(保存到出站汇报里(+关键件绑定))
        [Route("Cj_SingleStation/AddStationOutBillAndAssemblyBill")]
        [HttpPost]
        public object AddStationOutBillAndAssemblyBill([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg = _value.ToString();
                string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string sMainStr = sArray[0].ToString();//主表信息包含工序,班组,批次等信息
                string barCode_SN = sArray[1].ToString();//扫描的SN码镭雕码产品信息
                string sSubStr = sArray[2].ToString();//子表关键件信息
                string user = sArray[3].ToString();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-038]无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                string sExeReturnInfo = "";
                StationBill omodel = new StationBill();
                omodel = JsonConvert.DeserializeObject<StationBill>(sMainStr);
                List<Model.ClsSc_AssemblyBillSub> sub = new List<Model.ClsSc_AssemblyBillSub>();
                sub = JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(sSubStr);
                //判断是否有对应流转卡信息并获取
                ds = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_ProcessExchangeBillList");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //将流转卡信息写入
                    omodel.HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
                    omodel.HProcExchInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString());
                    omodel.HProcExchEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString());
                    omodel.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HMainMaterID"].ToString());
                    omodel.HCenterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCenterID"].ToString());
                    omodel.HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
                    omodel.HICMOInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOInterID"].ToString());
                    omodel.HICMOEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString());
                    omodel.HICMOQty = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOQty"].ToString());
                    omodel.HProcNo = ds.Tables[0].Rows[0]["HProcNo"].ToString();
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-2-019]]当前SN码和工序无法找到对应流转卡请检查是否输入选择错误";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //条码上道工序是否过站以及本道条码是否已经出站
                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_XW");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-045]查无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-051]" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //判断条码是否已经出站
                //ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 产品条码='" + barCode_SN + "' and HProcExchInterID=" + omodel.HProcExchInterID + " and HProcExchEntryID=" + omodel.HProcExchEntryID + " and HProcID=" + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
                //if (ds.Tables[0].Rows.Count > 0)
                //{
                //    oCN.RollBack();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "[0000-2-039]条码:" + barCode_SN + ",已出站!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //增加产线组装追溯单
                DataSet ds1;
                if (1==1)
                {
                    ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + barCode_SN + "'", "Sc_AssemblyBillMain");
                    if (ds1.Tables[0].Rows.Count == 0)
                    {
                        Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
                        string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
                        //保存生产组装单主表
                        string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
                        ,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
                        ,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID)
                        values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate()
                        ,'{HBillNo1}','1','{user}',getdate(),{omodel.HProcExchInterID.ToString()},{omodel.HProcExchEntryID.ToString()},'{omodel.HProcExchBillNo.ToString()}'
                        ,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{barCode_SN.ToString()}',{omodel.HMaterID},0,'汇报',{omodel.HPRDOrgID})";
                        oCN.RunProc(sql);
                        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,1
                            ,0,0,getdate(),'{sub[i].HBarCode}','{barCode_SN}','') ";
                            oCN.RunProc(sq2);
                        }
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "[0000-2-039]条码已存在绑定单:" + barCode_SN + "";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                long HMainInterID = 0;
                string BillType = "3791";
                string HBillSubType = "3791";
                long HInterID = omodel.HInterID;//递入type得到的单据ID
                string HBillNo = omodel.HBillNo;//递入type得到的单据号
                int HBillStatus = 1;
                string HMaker = user;//制单人
                string HMouldNum = omodel.HMouldNum;//模穴号
                int HYear = DateTime.Now.Year;
                double HPeriod = DateTime.Now.Month;
                string HRemark = omodel.HRemark;//备注
                string HSourceName = omodel.HSourceName;//生产资源名称
                double HPieceQty = omodel.HPieceQty;//进站PCS数
                double HWasterQty = 0;//报废数量
                double HPlanPieceQty = 0;//进站PNL数
                double HBadPNL = 0;//报废PNL数
                long HICMOInterID = omodel.HICMOInterID;//任务单ID
                long HICMOEntryID = omodel.HICMOEntryID;//任务单ID
                string HICMOBillNo = omodel.HICMOBillNo;//任务单
                int HProcPlanInterID = 0;
                int HProcPlanEntryID = 0;
                string HProcPlanBillNo = "";
                long HProcExchInterID = omodel.HProcExchInterID;
                long HProcExchEntryID = omodel.HProcExchEntryID;
                string HProcExchBillNo = omodel.HProcExchBillNo;//流转卡
                long HMaterID = omodel.HMaterID;//产品ID
                long HProcID = omodel.HProcID;//当前工序ID
                double HICMOQty = omodel.HICMOQty;//任务单数量
                double HPlanQty = omodel.HICMOQty;//移交PNL数
                DateTime HStationOutTime = DateTime.Now;//汇报时间
                long HSourceID = omodel.HSourceID;//生产资源ID
                long HPayProcID = 0;//核算工序ID
                long HGroupID = omodel.HGroupID;//班组ID
                long HDeptID = omodel.HDeptID;
                long HEmpID = omodel.HEmpID;//操作员ID
                long HEmpID2 = omodel.HEmpID2;////操作员2ID
                string HBarCode = barCode_SN;//条形码
                string HAddr = "";
                string HBarCodeMaker = "";
                long HSourceID2 = 0;//生产资源2ID
                long HSourceID3 = 0;//生产资源3ID
                long HSourceID4 = 0;//生产资源4ID
                long HSourceID5 = 0;//生产资源5ID
                long HSupID = 0;
                double HQty = omodel.HQty;//合格数量
                double HPrice = 0;
                double HMoney = 0;
                double HBadCount = omodel.HBadCount;//不良数量
                long HCenterID = omodel.HCenterID;//工作中心ID
                string HProcNo = omodel.HProcNo;//流水号
                string HOrderProcNO = omodel.HOrderProcNO;//订单跟踪号
                string HSourceNameList = omodel.HSourceNameList;//设备清单
                long HMainSourceInterID = omodel.HProcExchInterID;//递入type得到的单据ID
                string HMainSourceBillNo = omodel.HProcExchBillNo;//递入type得到的单据号
                string HMainSourceBillType = "3772";
                bool HLastSubProc = omodel.HLastSubProc;//转下工序
                long HEmpID3 = 0;//操作员3ID
                long HEmpID4 = 0;//操作员4ID
                long HEmpID5 = 0;//操作员5ID
                double HDSQty = 0;//折弯刀数
                double HChongQty = 0;//NCT冲次数
                double HPriceRate = 0;//系数
                double HWorkTimes = 0;//工时
                long HQCCheckID = omodel.HEmpID;//检验员ID
                long HPRDOrgID = omodel.HPRDOrgID;//组织ID
                double HmaterOutqty = 0;//白坯发布
                double HProcPriceRate = 0;//工价系数
                int HTemporaryAreaID = 0;//暂放区
                int HShiftsID = 0;
                string HBatchNo = omodel.HBatchNo;
                //获取当前班次
                //DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HDeptID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
                //if (set.Tables[0].Rows.Count > 0)
                //{
                //    HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
                //}
                //判断当天当前的流转卡是否有出站单
                HInterID = DBUtility.ClsPub.CreateBillID("3791", ref sExeReturnInfo);//递入type得到的单据ID
                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3791", ref sExeReturnInfo, true);//递入type得到的单据号
                //主表插入
                oCN.RunProc("Insert Into Sc_StationOutBillMain" +
                "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
                ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
                ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
                ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
                ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
                ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
                ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
                ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
                    ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
                ") " +
                " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
                "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
                "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 +
                "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
                "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
                "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HShiftsID + ") ");
                ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + omodel.HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
                oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HBatchNo)
                    values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{barCode_SN}', 1, GETDATE(), '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + $"', '', 0, 0,'{HBatchNo}')");
                //把条码写入日志里面
                LogService.CustomWriteLog("条码:" + barCode_SN + ",工序:" + 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);
                //=========================保存后控制
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_SingleStationOutBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + $@"',{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{barCode_SN}','{user}' ", "h_p_Sc_SingleStationOutBill_AfterSaveCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-016]保存后控制判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-051]保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //============================
                //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 = "[3791-2-028]出站数量超过流转卡数量!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-050]保存成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-051]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  工序单品过站 中箱码生成
        [Route("Cj_SingleStation/AddCaseCode")]
        [HttpPost]
        public object AddCaseCode([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg = _value.ToString();
                string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string sMainStr = sArray[0].ToString();//主表信息SN码档案id这种格式
                string user = sArray[1].ToString();
                oCN.BeginTran();
                ds = oCN.RunProcReturn("exec h_p_Gy_CaseCodeBySN '" + sMainStr + "'", "h_p_Sc_SNBarcodeProcCtrl_S");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-045]查无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-051]" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-050]保存成功!";
                objJsonResult.data = ds.Tables[0].Rows[0]["HBackRemark"].ToString();
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-051]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 过站解绑列表 查询
        [Route("Cj_SingleStation/UnbindBarList")]
        [HttpGet]
        public object BarList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Cj_SingleStation_UnbindBarList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList order by 条码日期 desc", "h_v_Sc_UnbindStation_BarList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_UnbindStation_BarList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 条码日期 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_UnbindStation_BarList");
                }
                //添加列名
                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/UnbindBarInfo")]
        [HttpGet]
        public object UnbindBarInfo(string HBarCodeIDs, string user)
        {
            try
            {
                if (HBarCodeIDs == null || HBarCodeIDs.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "重工条码信息未递入,请退出重试";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    string sql = "exec h_p_Sc_UnbindBarInfo '" + HBarCodeIDs + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_UnbindBarInfo");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 解除包装关系、拆除物料(1:解除包装关系;2.拆除物料)
        [Route("Cj_SingleStation/DelRelation")]
        [HttpGet]
        public object DelRelation(string HBarCodeIDs, Int64 HICMOInterID, Int64 HICMOEntryID, Int64 HProcID, Int64 HType, string user)
        {
            try
            {
                if (HBarCodeIDs == null || HBarCodeIDs.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "拆除条码信息未递入,请退出重试";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    string sql = "exec h_p_Sc_DelbindBarRelation '" + HBarCodeIDs + "'," + HICMOInterID + "," + HICMOEntryID + "," + HProcID + "," + HType;
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_DelbindBarRelation");
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() == "0")
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = ds.Tables[0].Rows[0]["HBackRemark"].ToString();
                    objJsonResult.data = "";
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
    }
}