yxj
2024-07-12 9b2e97ed6a3ba9ba86b3cd2961e1766c711af907
WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs
@@ -38,6 +38,7 @@
        {
            try
            {
                List<object> a = new List<object>();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 1, false, user))
                {
@@ -58,13 +59,19 @@
                    string sql = sql1 + sWhere + " order by hmainid desc ";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
                }
                foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
                {
                    Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接         // 将列名和数据类型信息拼接成一个JSON格式的字符串
                    a.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = a;
                return objJsonResult;
                //}
                //else
@@ -118,7 +125,9 @@
                {
                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,物料代码 HMaterCode,物料名称 HMaterName,规格型号 HMaterSpec,
                                            HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName,HSourceID,生产资源代码 HSourceCode,生产资源 HSourceName,
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注 HRemark
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注 HRemark,
                                            HICMOInterID,HICMOEntryID,HICMOBillNo,HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID,
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,不良数量 HBadQty
                                            FROM h_v_IF_ICMOReportBillList_Edit"), "h_v_IF_ICMOReportBillList_Edit");
                    objJsonResult.code = "0";
@@ -132,7 +141,10 @@
                    //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark  from Sc_MouldRepairCheckBillSub where 1 = 1 ";
                    string sql1 = string.Format(@"SELECT HMaterID,物料代码 HMaterCode,物料名称 HMaterName,规格型号 HMaterSpec,
                                            HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName,HSourceID,生产资源代码 HSourceCode,生产资源 HSourceName,
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注 HRemark
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注
                                            HRemark,HICMOInterID,HICMOEntryID,HICMOBillNo,
                                            HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID,
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,不良数量 HBadQty
                                            FROM h_v_IF_ICMOReportBillList_Edit where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
@@ -298,8 +310,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;     //关联数量
@@ -313,7 +325,7 @@
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.omodel.HInterID == 0)
                if (refSav == "Add")
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
@@ -493,9 +505,60 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                string HBillNo = "";
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Sc_ICMOReportBillMain where HInterID=" + lngBillKey, "Sc_ICMOReportBillMain");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult; ;
                }
                else
                {
                    HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                }
                //删除前控制=========================================
                DataSet Ds;
                string sql1 = "exec h_p_Sc_ICMOReportBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
                Ds = oCN.RunProcReturn(sql1, "h_p_Sc_ICMOReportBill_BeforeDelCtrl");
                if (Ds == null || Ds.Tables.Count == 0 || Ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                if (Ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!原因:" + Ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==================================================================================
                oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + "" + "','" + "删除生产汇报单单据:" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','LMES-生产汇报单模块','" + DBUtility.ClsPub.IPAddress + "','删除单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, HBillNo, "h_p_Sc_ICMOReportBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    oCN.Commit();//提交事务
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -504,11 +567,11 @@
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
            }
@@ -518,6 +581,7 @@
                objJsonResult.count = 0;
                objJsonResult.Message = "单据未找到";
                objJsonResult.data = null;
                oCN.RollBack();
                return objJsonResult;
            }
        }
@@ -537,6 +601,7 @@
        {
            string ModRightNameCheck = "Sc_ICMOReportBill_Check";
            DBUtility.ClsPub.CurUserName = CurUserName;
            string sql = "";
            try
            {
                //审核权限
@@ -611,8 +676,30 @@
                }
                if (IsAudit == 0) //审核提交
                {
                    //审核前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_ICMOReportBill_BeforeCheckCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核前控制===============================================End===================================================================
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.CheckBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_ICMOReportBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -622,8 +709,8 @@
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
@@ -631,8 +718,30 @@
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:反审核前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反审核前控制===============================================End===================================================================
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.AbandonCheck(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_ICMOReportBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -642,8 +751,8 @@
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
@@ -1103,5 +1212,108 @@
        }
        #endregion
        #region  生产汇报单获取源单产量汇报单临时表信息
        /// <summary>
        /// 生产汇报单获取源单产量汇报单临时表信息
        /// </summary>
        /// <returns></returns>
        [Route("Sc_ICMOReportBill/GetProdReportBillList")]
        [HttpGet]
        public object GetProdReportBillList(string HInterID, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "产量汇报单内码为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    string sql = "exec h_p_Sc_ICMOBillWorkQtyStatus_TmpList '" + HInterID + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ICMOBillWorkQtyStatus_TmpList");
                }
                //添加列名
                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列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds;
                objJsonResult.list = columnNameList;
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 生产汇报单 根据主内码与子内码获取生产汇报单数据
        [Route("Sc_ICMOReportBill/loadSc_ICMOReportBill_Push")]
        [HttpGet]
        public object loadSc_ICMOReportBill_Push(long HInterID, long HSubID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList_Edit where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_ICMOReportBillList_Edit");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未查询到源单信息!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    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
    }
}