zrg
2024-06-25 7a49829b614767de98100810d0c787e7130c1624
WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs
@@ -15,7 +15,8 @@
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSb_EquipDotCheckBill BillNew = new DAL.ClsSb_EquipDotCheckBill();   //对应单据类
        public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill();   //对应单据类
        public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill();   //对应单据类
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();   //获取系统参数
        #region 设备点检记录表
@@ -38,15 +39,34 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                string sReturn = "";
                string HViewName = "h_v_Sb_EquipDotCheckBillList";//视图命名
                if (oSystemParameter.ShowBill(ref sReturn) == true)
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sb_EquipDotCheckBillList " + sWhere + " order by hmainid desc", "h_v_Sb_EquipDotCheckBillList");
                    if (oSystemParameter.omodel.WMS_CampanyName == "九菱")
                    {
                        HViewName = "h_v_Sb_EquipDotCheckBillMainList";
                    }
                }
                else
                {
                    string sql1 = "select * from h_v_Sb_EquipDotCheckBillList where 1 = 1";
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据读取失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from " + HViewName + " " + sWhere + " order by hmainid desc", HViewName);
                }
                else
                {
                    string sql1 = "select * from " + HViewName + " " + " where 1 = 1";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBillList");
                    ds = oCN.RunProcReturn(sql, HViewName);
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -285,7 +305,29 @@
                    return objJsonResult;
                }
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                //删除前控制
                DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_Sb_EquipDotCheckBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + user + "'", "h_p_Sb_EquipDotCheckBill_BeforeDelCtrl");
                if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    objJsonResult.code = "0";
@@ -340,7 +382,7 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select 点检项目ID HDotCheckItemID,点检项目代码 as HDotCheckCode ,点检项目 HDotCheckItem,点检部位 HDotCheckPart ,具体要求 HClaim,表体备注 HRemark,负责人ID HManagerID,负责人编码 HManagerCode,负责人 HManagerName  from h_v_Sb_EquipDotCheckBillList", "h_v_Sb_EquipDotCheckBillList");
                    ds = oCN.RunProcReturn("select * from h_v_Sb_EquipDotCheckBill_Edit", "h_v_Sb_EquipDotCheckBill_Edit");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
@@ -348,9 +390,9 @@
                }
                else
                {
                    string sql1 = "select 点检项目ID HDotCheckItemID,点检项目代码 as HDotCheckCode ,点检项目 HDotCheckItem,点检部位 HDotCheckPart,具体要求 HClaim,表体备注 HRemark,负责人ID HManagerID,负责人编码 HManagerCode,负责人 HManagerName  from h_v_Sb_EquipDotCheckBillList where 1 = 1 ";
                    string sql1 = "select * from h_v_Sb_EquipDotCheckBill_Edit where 1 = 1 ";
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBillList");
                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBill_Edit");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
@@ -369,13 +411,8 @@
        #endregion
        #endregion
        #region 设备点检记录单PDA
        #region 根据设备条码查找设备档案信息PDA
        [Route("Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown")]
@@ -394,6 +431,49 @@
                }
                //得到信息
                ds = oCN.RunProcReturn("select top 1 * from Gy_EquipFileBillMain  where HEquipFileNumber= '" + HBarCode + "'", "Gy_EquipFileBillMain");
                //写入信息
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未查询到设备信息!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                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
        #region 根据设备条码查找设备档案信息PDA  查询条码档案列表
        [Route("Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_List")]
        [HttpGet]
        public object txtHBarCode_KeyDown_List(string HBarCode)
        {
            try
            {
                if (HBarCode == null || HBarCode.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "条形码不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //得到信息
                ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_EquipFileMainList  where 条形码= '" + HBarCode + "'", "h_v_Gy_EquipFileMainList");
                //写入信息
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
@@ -506,8 +586,8 @@
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = 0;     // 源单主内码
                    oItemSub.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceInterID = 0;     // 源单主内码
                    //oItemSub.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceBillNo = "";  //源单单号
                    //oItemSub.HSourceBillType = ""; //源单类型
                    //oItemSub.HRelationQty = 0;     //关联数量
@@ -710,7 +790,62 @@
        }
        #endregion
        #endregion
        #region 设备点检逾期预警报表
        [Route("Sb_EquipDotCheckWarning/Report")]
        [HttpGet]
        public object Report(string HYear,string HMonth,string HEquipTypeID, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //if (!DBUtility.ClsPub.Security_Log("Gy_EquipFileList", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "没有查看权限";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (HYear == null || HYear.Equals("") || HMonth == null || HMonth.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "请选择有效年份,月份";
                    objJsonResult.data = "";
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
                else
                {
                    string sql = "exec h_p_Sb_EquipDotCheckWarningReport " + HYear + "," + HMonth + "," + HEquipTypeID;
                    ds = oCN.RunProcReturn(sql, "h_p_Sb_EquipDotCheckWarningReport");
                }
                //添加列名
                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
    }
}