yangle
2023-12-01 19466feafef7d2be476ead4170d75af84781a9fe
WebAPI/Controllers/LMESController.cs
@@ -472,6 +472,48 @@
        }
        /// <summary>
        /// 工序流转卡的末道工序
        /// </summary>
        /// <param name="sBillBarCode"></param>
        /// <returns></returns>
        [Route("LEMS/TxtHBarCode_KeyDown_Last")]
        [HttpGet]
        public object TxtHBarCode_KeyDown_Last(string sBillBarCode)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sBillBarCode == null || sBillBarCode.Equals(""))
                {
                    return CustomError("未输入条形码!");
                }
                else
                {
                    //拆分条形码
                    string[] NewBarCode;
                    if (sBillBarCode.CompareTo("#") > 0)
                    {
                        NewBarCode = sBillBarCode.Split(Convert.ToChar("#"));
                        sBillBarCode = NewBarCode[0];
                    }
                    string sBillNo = sBillBarCode;
                    ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList  where 单据号= '" + sBillNo + "' and 末道工序='是' ", "h_v_Sc_ProcessExchangeBillList");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        return CustomError("不存在此流转卡号!");
                    }
                }
            }
            catch (Exception e)
            {
                ds = null;
            }
            return CustomCorrect(ds);
        }
        /// <summary>
        /// 流水号回车方法(进站接收单、出站汇报单)
        ///参数:string sql。
        ///返回值:object。
@@ -1037,13 +1079,13 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_ProductionLinePackagingList order by 唯一条码 desc", "h_v_ProductionLinePackagingList");
                    ds = oCN.RunProcReturn("select top 1000 * from h_v_ProductionLinePackagingList order by 扫码日期 desc, 唯一条码 desc", "h_v_ProductionLinePackagingList");
                }
                else
                {
                    string sql1 = "select * from h_v_ProductionLinePackagingList where 1 = 1 ";
                    string sql1 = "select top 1000 * from h_v_ProductionLinePackagingList where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    string sql2 = " order by 唯一条码 desc";
                    string sql2 = " order by 扫码日期 desc, 唯一条码 desc";
                    sql = sql + sql2;
                    ds = oCN.RunProcReturn(sql, "h_v_ProductionLinePackagingList");
                }
@@ -1056,6 +1098,36 @@
            return GetObjectJson(ds);
        }
        /// <summary>
        /// 删除对应的包装单
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        [Route("LEMS/DelMES_ProductionLinePackagingList")]
        [HttpGet]
        public object DelMES_ProductionLinePackagingList(string HInterID)
        {
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                oCN.RunProc("Delete from Sc_PackUnionBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete from Sc_PackUnionBillSub where HInterID = " + HInterID);
                oCN.RunProc("Delete from KF_PonderationBillMain_Temp where HInterID = " + HInterID);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!";
                objJsonResult.data = e.ToString();
                return objJsonResult;
            }
        }
        /// <summary>
        /// 扫批次条码方法(产线组装追溯单)--根据批次条码到条码档案表中获取数据保存到temp表
        ///参数:string sql。
@@ -1183,6 +1255,110 @@
            }
        }
        //判断条码是否是不良的状态
        [Route("LEMS/HbadStaus")]
        [HttpGet]
        public object HbadStaus(string SubBarcode)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn(@"select  HBillNo,HReasult from tiaom  where HBillNo='" + SubBarcode + @"'
union
select HBarCode HBillNo,HStatus HReasult from Gy_BarCodeBill
where HBarCode='" + SubBarcode + "'", "Gy_BarCodeBill");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "ok!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (ds.Tables[0].Rows[0]["HReasult"].ToString() =="不良")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前条码的状态为:"+ ds.Tables[0].Rows[0]["HReasult"].ToString() + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = null;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!";
                objJsonResult.data = e.ToString();
                return objJsonResult;
            }
        }
        //判断条码之前的工序是否出站
        [Route("LEMS/SNBarcodeProcCtrl")]
        [HttpGet]
        public object SNBarcodeProcCtrl(string SubBarcode,string HProcExchBillNo)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn(" select  * from Gy_BarCodeBill where HSourceBillNo='" + HProcExchBillNo + "' and HBarCode='" + SubBarcode + "'", "Gy_BarCodeBill");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查无数据,条码:" + SubBarcode + "不属于当前流转卡:" + HProcExchBillNo + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn(@"exec h_p_Sc_SNBarcodeProcCtrl '" + SubBarcode + "'", "h_p_Sc_SNBarcodeProcCtrl");
                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = null;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!";
                objJsonResult.data = e.ToString();
                return objJsonResult;
            }
        }
        //判断总的包装数量是否超过流转卡数量
        [Route("LEMS/h_p_Sc_ProductionLinePackaging_Checkqty")]
        [HttpGet]
@@ -1273,6 +1449,34 @@
            }
        }
        #region 打印查询数据
        [Route("Gy_SOPBillList/WindowPrintList")]
        [HttpGet]
        public object WindowPrintList(string sWhere)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn(sWhere, "WindowPrint");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        //
    }
}