yusijie
2024-02-21 1ce0de5fe9438f3f237bdce8e261be94eee64a2b
WebAPI/Controllers/ÏîÄ¿¹ÜÀí/¹¤×÷ÈÎÎñ/PM_WorkTaskBillController.cs
@@ -64,6 +64,7 @@
            public int HMainSourceEntryID;
            public string HMainSourceBillNo;
            public string HMainSourceBillType;
            public int HOrderLevID;
        }
        #endregion
@@ -181,6 +182,8 @@
                int HMainSourceEntryID = mainList[0].HMainSourceEntryID;
                string HMainSourceBillNo = mainList[0].HMainSourceBillNo;
                string HMainSourceBillType = mainList[0].HMainSourceBillType;
                int HOrderLevID = mainList[0].HOrderLevID;
                if (OperationType == 2)
@@ -202,7 +205,7 @@
                {
                    string sql = "insert into PM_WorkTaskBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType)" +
                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID)" +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
@@ -223,7 +226,7 @@
                        "','" + HReceiveEmp +
                        "','" + HType +
                        "','" + HCopyEmp +
                        "','" + HRemark +
                        "','" + HRemark +
                        "'," + HOrgID +
                        ",'" + HMaker +
                        "','" + HMakerDate +
@@ -231,6 +234,7 @@
                        "," + HMainSourceEntryID +
                        ",'" + HMainSourceBillNo +
                        "','" + HMainSourceBillType +
                        "','" + HOrderLevID  +
                        "')";
                    //主表
@@ -267,6 +271,7 @@
                        ",HMainSourceEntryID = " + HMainSourceEntryID +
                        ",HMainSourceBillNo = '" + HMainSourceBillNo +
                        "',HMainSourceBillType = '" + HMainSourceBillType +
                        "',HOrderLevID  = '" + HOrderLevID  +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
@@ -280,7 +285,7 @@
                {
                    string sql = "insert into PM_WorkTaskBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType)" +
                        ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID )" +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
@@ -309,6 +314,7 @@
                        "," + HMainSourceEntryID +
                        ",'" + HMainSourceBillNo +
                        "','" + HMainSourceBillType +
                        "','" + HOrderLevID +
                        "')";
                    //主表
                    oCN.RunProc(sql);
@@ -401,6 +407,101 @@
                    string sql = sql1 + sWhere + " order by å•据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskBillList");
                }
                //添加列名
                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 å·¥ä½œä»»åŠ¡åˆ—è¡¨  ä¸‹æŽ¨æ•°æ®æŸ¥è¯¢
        /// <summary>
        /// è¿”回项目阶段列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("PM_WorkTaskBill/XTList")]
        [HttpGet]
        public object XTList(string HInterID,string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskBillMyList  where HInterID ='"+ HInterID + "'   and æŽ¥å•人='"+user+"'", "h_v_PM_WorkTaskBillMyList");
                //添加列名
                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 è®¢å•等级列表 æŸ¥è¯¢
        /// <summary>
        /// è¿”回项目阶段列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("PM_WorkTaskBill/getOrder")]
        [HttpGet]
        public object getOrder()
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //if (HItemID == null || HItemID.Equals(""))
                //{
                //ds = oCN.RunProcReturn("select * from Gy_OrderLev ", "Gy_OrderLev");
                //}
                //else
                //{
                //    string sql = "select * from Gy_OrderLev where HItemID='"+ HItemID + "'";
                //    ds = oCN.RunProcReturn(sql, "Gy_OrderLev");
                //}
                ds = oCN.RunProcReturn("select * from Gy_OrderLev ", "Gy_OrderLev");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -961,6 +1062,163 @@
        }
        #endregion
        #region å·¥ä½œä»»åŠ¡  å¼€å§‹ä»»åŠ¡/撤销开始功能
        [Route("PM_WorkTaskBill/BeginPM_WorkTaskBill")]
        [HttpGet]
        public object BeginPM_WorkTaskBill(string HInterID, int Type, string user)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "PM_WorkTaskBillMain";
                oCN.BeginTran();//开始事务
                //Type 0 å¼€å§‹ä»»åŠ¡  1  æ’¤é”€ä»»åŠ¡  2结束任务
                if (Type == 0)
                {
                    //判断单据是否存在
                    DataSet ds;
                    string sql = "select * from PM_WorkTaskBillMain  where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HMainSourceBillType"])== "4759")
                        {
                            var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"];
                            string sql1 = "update  PM_WorkTaskBillMain   set  HTaskStatus='已开始' where HinterID = " + HInterID;
                            oCN.RunProc(sql1);
                            string sql2 = "update PM_CustomerTaskBillMain  set  HTaskStatus='已开始' where HinterID = " + lInterID;
                            oCN.RunProc(sql2);
                        }
                        else
                        {
                            string sql2 = "update PM_WorkTaskBillMain  set  HTaskStatus='已开始' where HinterID = " + HInterID;
                            oCN.RunProc(sql2);
                        }
                    }
                }
                else if(Type==1)
                {
                    //判断单据是否存在
                    DataSet ds;
                    string sql = "select * from PM_WorkTaskBillMain  where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"];
                        string sql1 = "update PM_WorkTaskBillMain  set   HTaskStatus='未开始' where HinterID = " + HInterID;
                        oCN.RunProc(sql1);
                        string sql2 = "update PM_CustomerTaskBillMain   set  HTaskStatus='未开始' where HinterID = " + lInterID;
                        oCN.RunProc(sql2);
                    }
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥ä½œä»»åŠ¡  å‚¬ä¿ƒæ¬¡æ•°åŠŸèƒ½
        [Route("PM_WorkTaskBill/UpdateHHasten")]
        [HttpGet]
        public object UpdateHHasten(string HInterID, int HHasten, string user)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "PM_WorkTaskBillMain";
                oCN.BeginTran();//开始事务
                DataSet ds;
                string sql = "select * from PM_WorkTaskBillMain  where HinterID = " + HInterID;
                ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    string sql1 = "update PM_WorkTaskBillMain  set   HHasten='"+ HHasten+ "' where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql1, "PM_WorkTaskBillMain");
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ä»»åŠ¡æ±‡æŠ¥ æ–°å¢ž/编辑-保存
        #region ä»»åŠ¡æ±‡æŠ¥ è¡¨å¤´æ•°æ®
        public class PM_WorkTaskReportBill_Main
@@ -1266,6 +1524,30 @@
                string HSourceBillNo = oSub.HSourceBillNo;
                string HSourceBillType = oSub.HSourceBillType;
                bool HFinishFlag = oSub.HFinishFlag;
                if (HFinishFlag==true)
                {
                    //判断单据是否存在
                    DataSet ds;
                    string sqls = "select * from PM_WorkTaskBillMain  where HinterID = " + HSourceInterID;
                    ds = oCN.RunProcReturn(sqls, "PM_WorkTaskBillMain");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"];
                        string sql1 = "update PM_WorkTaskBillMain  set   HTaskStatus='已完成' where HinterID = " + HSourceInterID;
                        oCN.RunProc(sql1);
                        string sql2 = "update PM_CustomerTaskBillMain   set   HTaskStatus='已完成' where HinterID = " + lInterID;
                        oCN.RunProc(sql2);
                    }
                }
                string sql = "insert into PM_WorkTaskReportBillSub" +
                    "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag) " +
@@ -2014,15 +2296,6 @@
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                    }
                    //添加列名
                    foreach (DataColumn col in ds.Tables[1].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!";
@@ -2050,5 +2323,7 @@
            }
        }
        #endregion
    }
}