From 1ce0de5fe9438f3f237bdce8e261be94eee64a2b Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期三, 21 二月 2024 17:32:42 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/项目管理/工作任务/PM_WorkTaskBillController.cs | 1172 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 984 insertions(+), 188 deletions(-) diff --git "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" index 36355ed..75d10cd 100644 --- "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" +++ "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" @@ -29,6 +29,7 @@ { public int HInterID; public string HBillNo; + public int HProjectID; public string HProNumber; public string HProName; public int HProjectStageID; @@ -58,6 +59,12 @@ public string HDeleteManDate; public string HBackerDate; public string HBackRemark; + + public int HMainSourceInterID; + public int HMainSourceEntryID; + public string HMainSourceBillNo; + public string HMainSourceBillType; + public int HOrderLevID; } #endregion @@ -141,6 +148,7 @@ string HBillSubType = ""; int HInterID = mainList[0].HInterID; string HBillNo = mainList[0].HBillNo; + int HProjectID = mainList[0].HProjectID; string HProNumber = mainList[0].HProNumber; string HProName = mainList[0].HProName; int HProjectStageID = mainList[0].HProjectStageID; @@ -170,6 +178,12 @@ string HDeleteManDate = mainList[0].HDeleteManDate; string HBackerDate = mainList[0].HBackerDate; string HBackRemark = mainList[0].HBackRemark; + int HMainSourceInterID = mainList[0].HMainSourceInterID; + int HMainSourceEntryID = mainList[0].HMainSourceEntryID; + string HMainSourceBillNo = mainList[0].HMainSourceBillNo; + string HMainSourceBillType = mainList[0].HMainSourceBillType; + int HOrderLevID = mainList[0].HOrderLevID; + if (OperationType == 2) @@ -190,8 +204,8 @@ if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板 { string sql = "insert into PM_WorkTaskBillMain" + - "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" + - ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate)" + + "(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,HOrderLevID)" + "values(" + "" + HYear + "," + HPeriod + @@ -199,7 +213,8 @@ "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + - "','" + HProNumber + + "'," + HProjectID + + ",'" + HProNumber + "'," + HProjectStageID + ",'" + HName + "','" + HDate + @@ -211,10 +226,15 @@ "','" + HReceiveEmp + "','" + HType + "','" + HCopyEmp + - "','" + HRemark + + "','" + HRemark + "'," + HOrgID + ",'" + HMaker + "','" + HMakerDate + + "'," + HMainSourceInterID + + "," + HMainSourceEntryID + + ",'" + HMainSourceBillNo + + "','" + HMainSourceBillType + + "','" + HOrderLevID + "')"; //涓昏〃 @@ -230,7 +250,8 @@ ",HBillType = '" + HBillType + "',HBillSubType = '" + HBillSubType + "',HBillNo = '" + HBillNo + - "',HProNumber = '" + HProNumber + + "',HProjectID = " + HProjectID + + ",HProNumber = '" + HProNumber + "',HProjectStageID = " + HProjectStageID + ",HName = '" + HName + "',HDate = '" + HDate + @@ -246,6 +267,11 @@ "',HOrgID = " + HOrgID + ",HUpdater = '" + HUpdater + "',HUpdateDate = '" + HUpdaterDate + + "',HMainSourceInterID = " + HMainSourceInterID + + ",HMainSourceEntryID = " + HMainSourceEntryID + + ",HMainSourceBillNo = '" + HMainSourceBillNo + + "',HMainSourceBillType = '" + HMainSourceBillType + + "',HOrderLevID = '" + HOrderLevID + "' where HInterID = " + HInterID; oCN.RunProc(sql); @@ -255,7 +281,47 @@ //璁板綍鏃ュ織 LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼宸ヤ綔浠诲姟:" + HBillNo); oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼宸ヤ綔浠诲姟锛�" + HBillNo + "','LMES-宸ヤ綔浠诲姟妯″潡','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); + }else if (OperationType == 4 && ds.Tables[0].Rows.Count == 0) //涓嬫帹 + { + 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,HOrderLevID )" + + "values(" + + "" + HYear + + "," + HPeriod + + ",'" + HBillType + + "','" + HBillSubType + + "'," + HInterID + + ",'" + HBillNo + + "'," + HProjectID + + ",'" + HProNumber + + "'," + HProjectStageID + + ",'" + HName + + "','" + HDate + + "','" + HTaskNote + + "'," + HPlanTimes + + "," + HSelfTimes + + ",'" + HLastDate + + "','" + HSendEmp + + "','" + HReceiveEmp + + "','" + HType + + "','" + HCopyEmp + + "','" + HRemark + + "'," + HOrgID + + ",'" + HMaker + + "','" + HMakerDate + + "'," + HMainSourceInterID + + "," + HMainSourceEntryID + + ",'" + HMainSourceBillNo + + "','" + HMainSourceBillType + + "','" + HOrderLevID + + "')"; + //涓昏〃 + oCN.RunProc(sql); + LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板宸ヤ綔浠诲姟:" + HBillNo); + oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板宸ヤ綔浠诲姟锛�" + HBillNo + "','LMES-宸ヤ綔浠诲姟妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); } + //淇濆瓨瀛愯〃 objJsonResult = AddBillSub(HInterID, HBillNo, OperationType); @@ -333,14 +399,109 @@ if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select * from PM_WorkTaskBillMain order by HBillNo ", "PM_WorkTaskBillMain"); + ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskBillList order by 鍗曟嵁鍙� desc", "h_v_PM_WorkTaskBillList"); } else { - string sql1 = "select * from PM_WorkTaskBillMain where 1 = 1 "; - string sql = sql1 + sWhere + " order by HBillNo "; - ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain"); + string sql1 = "select * from h_v_PM_WorkTaskBillList where 1 = 1 "; + 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + 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> + /// 杩斿洖椤圭洰闃舵鍒楄〃 + ///鍙傛暟锛歴tring 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + 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> + /// 杩斿洖椤圭洰闃舵鍒楄〃 + ///鍙傛暟锛歴tring 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) @@ -481,26 +642,67 @@ /// <returns></returns> [Route("PM_WorkTaskBill/AuditPM_WorkTaskBill")] [HttpGet] - public object AuditPM_WorkTaskBill(int HInterID, int IsAudit, string CurUserName) + public object AuditPM_WorkTaskBill(string HInterID, int Type, string user) { try { - //瀹℃牳鏉冮檺 - if (!DBUtility.ClsPub.Security_Log_second("Pm_WorkTaskBill_Check", 1, false, CurUserName)) + //鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_Check", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.Message = "鏃犳潈闄愬鏍�!"; objJsonResult.data = null; return objJsonResult; } - var ds = oCN.RunProcReturn("select * from PM_WorkTaskBillMain where HInterID=" + HInterID, "PM_WorkTaskBillMain"); - if (ds.Tables[0].Rows.Count > 0) + if (string.IsNullOrWhiteSpace(HInterID)) { - if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "PM_WorkTaskBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 瀹℃牳 2 鍙嶅鏍� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) { - if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + 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 (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -508,14 +710,12 @@ objJsonResult.data = null; return objJsonResult; } - } - if (IsAudit == 1) //鍙嶅鏍稿垽鏂� - { - if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + //瀹℃牳鍗曟嵁 + if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } @@ -523,43 +723,62 @@ } else { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; - objJsonResult.data = null; - return objJsonResult; + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘杩涜鍙嶅鏍革紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍙嶅鏍革紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅鏍稿崟鎹� + if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } } - oCN.BeginTran(); + oCN.Commit();//鎻愪氦浜嬪姟 - if (IsAudit == 0) //瀹℃牳鍒ゆ柇 - { - oCN.RunProc("update PM_WorkTaskBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "瀹℃牳鎴愬姛"; - objJsonResult.data = null; - } - if (IsAudit == 1) //鍙嶅鏍稿垽鏂� - { - oCN.RunProc("update PM_WorkTaskBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID); - - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶅鏍告垚鍔�"; - objJsonResult.data = null; - } - oCN.Commit(); - - return objJsonResult; } catch (Exception e) { - oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } @@ -603,25 +822,50 @@ DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + 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 (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!"; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!"; objJsonResult.data = null; return objJsonResult; } - } - //鍏抽棴鍗曟嵁 - if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //鍏抽棴鍗曟嵁 + if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } else @@ -632,23 +876,39 @@ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插弽鍏抽棴!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!"; objJsonResult.data = null; return objJsonResult; } - } - //鍙嶅叧闂崟鎹� - if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //鍙嶅叧闂崟鎹� + if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } @@ -709,8 +969,24 @@ DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + 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 (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") { objJsonResult.code = "0"; @@ -719,15 +995,15 @@ objJsonResult.data = null; return objJsonResult; } - } - //浣滃簾鍗曟嵁 - if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //浣滃簾鍗曟嵁 + if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } else @@ -738,24 +1014,189 @@ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插弽浣滃簾!涓嶉渶瑕佸啀鍙嶄綔搴�!"; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸啀鍙嶄綔搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶄綔搴熷崟鎹� + if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } - //鍙嶄綔搴熷崟鎹� - if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + } + + 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 宸ヤ綔浠诲姟 寮�濮嬩换鍔�/鎾ら攢寮�濮嬪姛鑳� + [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 = 1; - objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + 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();//鎻愪氦浜嬪姟 @@ -783,6 +1224,10 @@ public class PM_WorkTaskReportBill_Main { public int HInterID; + public int HProID; + public int HProjectStageID; + public string HMainSourceBillNo; + public string HMainSourceBillType; public string HBillNo; public string HDate; public string HRemark; @@ -808,6 +1253,7 @@ public class PM_WorkTaskReportBill_Sub { public int RowID; + public int HProjectID; public string HProNumber; public int HProjectStageID; public string HProjectStageName; @@ -818,9 +1264,14 @@ public string HReportNote; public string HAdv; public string HRemarkSub; + public int HSourceInterID; + public int HSourceEntryID; + public string HSourceBillNo; + public string HSourceBillType; + public bool HFinishFlag; } #endregion - #region 椤圭洰闃舵娓呭崟 鏂板/缂栬緫-淇濆瓨 + #region 浠诲姟姹囨姤 鏂板/缂栬緫-淇濆瓨 /// <summary> /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -854,7 +1305,7 @@ return objJsonResult; } #endregion - #region 娣诲姞 椤圭洰闃舵娓呭崟 涓昏〃 + #region 娣诲姞 浠诲姟姹囨姤 涓昏〃 public json AddBillMain_WorkTaskReportBill(string msg1) { string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); @@ -901,6 +1352,10 @@ string HBillSubType = ""; int HBillStatus = 1; int HInterID = mainList[0].HInterID; + int HProID = mainList[0].HProID; + int HProjectStageID = mainList[0].HProjectStageID; + string HMainSourceBillNo = mainList[0].HMainSourceBillNo; + string HMainSourceBillType = mainList[0].HMainSourceBillType; string HBillNo = mainList[0].HBillNo; string HDate = mainList[0].HDate; string HRemark = mainList[0].HRemark; @@ -912,16 +1367,23 @@ string HUpdater = mainList[0].HUpdater; string HUpdaterDate = mainList[0].HUpdaterDate; - - - if (OperationType == 2) + //淇濆瓨鍓嶆帶鍒� + DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_PM_WorkTaskReportBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_PM_WorkTaskReportBill_BeforeSaveCtrl"); + if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) { - ds = oCN.RunProcReturn("select * from PM_WorkTaskReportBillMain where HBillNo ='" + HBillNo + "'", "PM_WorkTaskReportBillMain"); - if (ds.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 = "鍗曟嵁鍙烽噸澶�,璇烽噸鏂拌緭鍏�!"; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); objJsonResult.data = null; return objJsonResult; } @@ -973,11 +1435,41 @@ oCN.RunProc(sql); + //鍒犻櫎瀛愯〃鏃� 鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬� + oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString()); //鍒犻櫎瀛愯〃 oCN.RunProc("delete from PM_WorkTaskReportBillSub where HInterID='" + HInterID + "'"); //璁板綍鏃ュ織 LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼椤圭洰闃舵娓呭崟:" + HBillNo); oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼椤圭洰闃舵娓呭崟锛�" + HBillNo + "','LMES-椤圭洰闃舵娓呭崟妯″潡','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); + }else if(OperationType == 4 && ds.Tables[0].Rows.Count == 0) //涓嬫帹 + { + string sql = "insert into PM_WorkTaskReportBillMain" + + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HOrgID,HReportEmpID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType,HMainSourceBillNo) " + + "values(" + + "" + HYear + + "," + HPeriod + + ",'" + HBillType + + "','" + HBillSubType + + "'," + HInterID + + ",'" + HDate + + "','" + HBillNo + + "'," + HBillStatus + + ",'" + HRemark + + "','" + HMaker + + "','" + HMakerDate + + "'," + HOrgID + + "," + HReportEmpID + + "," + HProID + + "," + HProjectStageID + + ",'" + HMainSourceBillType + + "','" + HMainSourceBillNo + + "')"; + + //涓昏〃 + oCN.RunProc(sql); + LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板浠诲姟姹囨姤:" + HBillNo); + oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板浠诲姟姹囨姤锛�" + HBillNo + "','LMES-浠诲姟姹囨姤妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo); } //淇濆瓨瀛愯〃 objJsonResult = AddBillSub_WorkTaskReportBill(msg3, HInterID, HBillNo, OperationType); @@ -1007,7 +1499,7 @@ } } #endregion - #region 娣诲姞椤圭洰闃舵娓呭崟 瀛愯〃 + #region 娣诲姞浠诲姟姹囨姤 瀛愯〃 public json AddBillSub_WorkTaskReportBill(string msg3, long HInterID, string HBillNo, int OperationType) { List<PM_WorkTaskReportBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_WorkTaskReportBill_Sub>>(msg3); @@ -1017,6 +1509,7 @@ i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷 int HEntryID = i; + int HProjectID = oSub.HProjectID; string HProNumber = oSub.HProNumber; int HProjectStageID = oSub.HProjectStageID; string HName = oSub.HName; @@ -1026,15 +1519,45 @@ string HReportNote = oSub.HReportNote; string HAdv = oSub.HAdv; string HRemark = oSub.HRemarkSub; + int HSourceInterID = oSub.HSourceInterID; + int HSourceEntryID = oSub.HSourceEntryID; + 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,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv) " + + "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag) " + "values(" + "" + HInterID + ",'" + HBillNo + "'," + HEntryID + ",'" + HRemark + - "','" + HProNumber + + "'," + HProjectID + + ",'" + HProNumber + "'," + HProjectStageID + ",'" + HName + "','" + HTaskNote + @@ -1042,16 +1565,48 @@ "'," + HRelTimes + ",'" + HReportNote + "','" + HAdv + - "')"; + "'," + HSourceInterID + + "," + HSourceEntryID + + ",'" + HSourceBillType + + "','" + HSourceBillNo + + "'," + DBUtility.ClsPub.BoolToString(HFinishFlag) + + ")"; oCN.RunProc(sql); } - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = null; - objJsonResult.data = null; - return objJsonResult; + //淇濆瓨鍚庢帶鍒� + DataSet AfterDs = oCN.RunProcReturn("Exec h_p_PM_WorkTaskReportBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_PM_WorkTaskReportBill_AfterSaveCtrl"); + if (AfterDs == null || AfterDs.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isLong(AfterDs.Tables[0].Rows[0]["HBack"]) == 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(AfterDs.Tables[0].Rows[0]["HRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + else + { + //鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬� + oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Add " + HInterID.ToString()); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + objJsonResult.data = null; + return objJsonResult; + } + } } #endregion #endregion @@ -1081,13 +1636,13 @@ if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select * from PM_WorkTaskReportBillMain order by HBillNo desc ", "PM_ProjectStageBillMain"); + ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskReportBillList order by 鍗曟嵁鍙� desc", "h_v_PM_ProjectStageBillList"); } else { - string sql1 = "select * from PM_WorkTaskReportBillMain where 1 = 1 "; - string sql = sql1 + sWhere + " order by HBillNo desc "; - ds = oCN.RunProcReturn(sql, "PM_WorkTaskReportBillMain"); + string sql1 = "select * from h_v_PM_WorkTaskReportBillList where 1 = 1 "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskReportBillList"); } //娣诲姞鍒楀悕 @@ -1201,6 +1756,8 @@ oCN.BeginTran(); + //鍒犻櫎瀛愯〃鏃� 鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬� + oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString()); oCN.RunProc("delete from PM_WorkTaskReportBillMain where HInterID = " + HInterID); oCN.RunProc("delete from PM_WorkTaskReportBillSub where HInterID='" + HInterID + "'"); @@ -1208,7 +1765,7 @@ objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; + objJsonResult.Message = "鍒犻櫎鎴愬姛锛�"; objJsonResult.data = null; return objJsonResult; } @@ -1233,26 +1790,67 @@ /// <returns></returns> [Route("PM_WorkTaskReportBill/AuditPM_WorkTaskReportBill")] [HttpGet] - public object AuditPM_WorkTaskReportBill(int HInterID, int IsAudit, string CurUserName) + public object AuditPM_WorkTaskReportBill(string HInterID, int Type, string user) { try { - //瀹℃牳鏉冮檺 - if (!DBUtility.ClsPub.Security_Log_second("Pm_WorkTaskReportBill_Check", 1, false, CurUserName)) + //鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_Check", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.Message = "鏃犳潈闄愬鏍�!"; objJsonResult.data = null; return objJsonResult; } - var ds = oCN.RunProcReturn("select * from PM_WorkTaskReportBillMain where HInterID=" + HInterID, "PM_WorkTaskReportBillMain"); - if (ds.Tables[0].Rows.Count > 0) + if (string.IsNullOrWhiteSpace(HInterID)) { - if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "PM_WorkTaskReportBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 瀹℃牳 2 鍙嶅鏍� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) { - if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + 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 (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -1260,14 +1858,12 @@ objJsonResult.data = null; return objJsonResult; } - } - if (IsAudit == 1) //鍙嶅鏍稿垽鏂� - { - if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + //瀹℃牳鍗曟嵁 + if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } @@ -1275,43 +1871,62 @@ } else { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; - objJsonResult.data = null; - return objJsonResult; + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘杩涜鍙嶅鏍革紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍙嶅鏍革紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅鏍稿崟鎹� + if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } } - oCN.BeginTran(); + oCN.Commit();//鎻愪氦浜嬪姟 - if (IsAudit == 0) //瀹℃牳鍒ゆ柇 - { - oCN.RunProc("update PM_WorkTaskReportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "瀹℃牳鎴愬姛"; - objJsonResult.data = null; - } - if (IsAudit == 1) //鍙嶅鏍稿垽鏂� - { - oCN.RunProc("update PM_WorkTaskReportBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID); - - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶅鏍告垚鍔�"; - objJsonResult.data = null; - } - oCN.Commit(); - - return objJsonResult; } catch (Exception e) { - oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } @@ -1355,25 +1970,50 @@ DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + 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 (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!"; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!"; objJsonResult.data = null; return objJsonResult; } - } - //鍏抽棴鍗曟嵁 - if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //鍏抽棴鍗曟嵁 + if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } else @@ -1384,23 +2024,39 @@ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插弽鍏抽棴!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!"; objJsonResult.data = null; return objJsonResult; } - } - //鍙嶅叧闂崟鎹� - if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //鍙嶅叧闂崟鎹� + if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } @@ -1461,8 +2117,24 @@ DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + 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 (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") { objJsonResult.code = "0"; @@ -1471,15 +2143,15 @@ objJsonResult.data = null; return objJsonResult; } - } - //浣滃簾鍗曟嵁 - if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //浣滃簾鍗曟嵁 + if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } else @@ -1490,23 +2162,31 @@ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插弽浣滃簾!涓嶉渶瑕佸啀鍙嶄綔搴�!"; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸啀鍙嶄綔搴�!"; objJsonResult.data = null; return objJsonResult; } - } - //鍙嶄綔搴熷崟鎹� - if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; + //鍙嶄綔搴熷崟鎹� + if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } } } @@ -1529,5 +2209,121 @@ } } #endregion + + #region 鏍规嵁鐧诲綍璐︽埛鑾峰彇瀵逛簬鑱屽憳 + [Route("PM_WorkTaskReportBill/getHEmpByHUserName")] + [HttpGet] + public object getHEmpByHUserName(string Czybm, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //鏌ョ湅鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + string sql = @"select a.HEmpID,b.HName HEmpName + from Gy_Czygl AS a + LEFT OUTER JOIN Gy_Employee AS b on a.HEmpID = b.HItemID + where a.Czybm = '" + Czybm + "'"; + + ds = oCN.RunProcReturn(sql, "Gy_Czygl"); + + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈壘鍒扮浉鍏虫暟鎹紒"; + objJsonResult.data = null; + return objJsonResult; + } + + + //娣诲姞鍒楀悕 + 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + 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> + /// 杩斿洖鎴戠殑浠诲姟鍒楄〃 + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("PM_WorkTaskBill/PM_WorkTaskBillMainList")] + [HttpGet] + public object PM_WorkTaskBillMainList( string user) + { + try + { + List<object> columnNameList = new List<object>(); + + ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskBillMyList " + user, "h_p_PM_WorkTaskBillMyList"); + + if (ds.Tables[0].Rows.Count != 0 || ds != null) + { + //娣诲姞鍒楀悕 + 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + 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 e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + } } \ No newline at end of file -- Gitblit v1.9.1