From 849e974e20d9894f3da95ebf504d97ce9f14c9ed Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期四, 05 十二月 2024 15:03:25 +0800
Subject: [PATCH] 工艺路线撤回,出站汇报单修改时间功能能
---
WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs | 352 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 338 insertions(+), 14 deletions(-)
diff --git a/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs b/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs
index b0b9678..00cbd97 100644
--- a/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs
+++ b/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs
@@ -1,10 +1,12 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
+using System.Globalization;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers
@@ -29,6 +31,7 @@
{
try
{
+ List<object> columnNameList = new List<object>();
if (sWhere == null || sWhere.Equals(""))
{
ds = oCN.RunProcReturn("select * from h_v_Xt_AccountPeriodList " + sWhere, "h_v_Xt_AccountPeriodList");
@@ -39,22 +42,197 @@
string sql = sql1 + sWhere;
ds = oCN.RunProcReturn(sql, "h_v_Xt_AccountPeriodList");
}
- if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+ //娣诲姞鍒楀悕
+ foreach (DataColumn col in ds.Tables[0].Columns)
{
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
- objJsonResult.data = null;
- return objJsonResult;
+ Type dataType = col.DataType;
+ string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+ columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
}
- else
+
+ //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 = 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;
+ }
+ }
+
+ /// <summary>
+ /// 淇敼鍗曟嵁-淇濆瓨鎸夐挳
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Xt_AccountPeriod/AddBill1")]
+ [HttpPost]
+ public object AddBill1([FromBody] JObject oMain)
+ {
+
+ try
+ {
+ var _value = oMain["oMain"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string msg3 = sArray[1].ToString();
+ string msg4 = sArray[2].ToString();
+ string msg5 = sArray[3].ToString();
+ //鍙嶅簭鍒楀寲
+ msg2 = "[" + msg2.ToString() + "]";
+ List<Xt_AccountPeriod> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Xt_AccountPeriod>>(msg2);
+
+ long HItemID = list[0].id;
+ long HYear = list[0].HYear;
+ long HPeriod = list[0].HPeriod;
+ DateTime HBeginDate = list[0].HBeginDate;
+ DateTime HEndDate = list[0].HEndDate;
+ string HEndFlag = list[0].HEndFlag;
+
+
+
+ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+ oCN.BeginTran();
+ //涓昏〃
+ oCN.RunProc("Update Xt_AccountPeriod set " +
+ " HYear=" + HYear +
+ ",HPeriod=" + HPeriod +
+ ",HBeginDate='" + HBeginDate + "'" +
+ ",HEndDate='" + HEndDate + "'" +
+ ",HEndFlag= '" + HEndFlag + "' HYear=" + HYear + " and HPeriod=" + HPeriod, ref DBUtility.ClsPub.sExeReturnInfo);
+ //淇敼瀛愰」鐩唬鐮�
+ //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
+ //灏嗕笂绾� 涓洪潪鏈骇
+ //
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "淇敼鍗曟嵁鎴愬姛锛�";
+ //objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+
+ /// <summary>
+ /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Xt_AccountPeriod/AddBill")]
+ [HttpPost]
+ public object AddBill([FromBody] JObject oMain)
+ {
+ try
+ {
+ var _value = oMain["oMain"].ToString();
+ string msg1 = _value.ToString();
+ //鍙嶅簭鍒楀寲
+ msg1 = "[" + msg1.ToString() + "]";
+
+
+
+ List<Xt_AccountPeriod> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Xt_AccountPeriod>>(msg1);
+
+ long HYear = list[0].HYear;
+ long HPeriod = list[0].HPeriod;
+ DateTime HBeginDate = list[0].HBeginDate;
+ DateTime HEndDate = list[0].HEndDate;
+ string HEndFlag = "1";
+
+
+
+
+
+
+
+ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+ oCN.BeginTran();
+ //涓昏〃
+ oCN.RunProc("Insert Into Xt_AccountPeriod " +
+ "(HYear,HPeriod,HBeginDate,HEndDate" +
+ ",HEndFlag" +
+ ") " +
+ " values('" + HYear + "','" + HPeriod + "','" + HBeginDate + "','" + HEndDate +
+ "','" + HEndFlag + "'" +
+ ") ");
+ //淇敼涓婄骇涓洪潪鏈骇浠g爜
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "缁撹处鎴愬姛锛�";
+ //objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 浼氳鏈熼棿鍒楄〃鍙嶇粨璐︽寜閽�
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Xt_AccountPeriod/Update_Json")]
+ [HttpGet]
+ public object Update_Json(long HYear, long HPeriod ,string num)
+ {
+ try
+ {
+ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+ oCN.BeginTran();
+ if (num=="1")//缁撹处
{
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "Sucess锛�";
- objJsonResult.data = ds.Tables[0];
- return objJsonResult;
+ oCN.RunProc("update Xt_AccountPeriod set HEndFlag=1 Where HYear =" + HYear + " and HPeriod=" + HPeriod, ref DBUtility.ClsPub.sExeReturnInfo);
}
+ else//鍙嶇粨璐�
+ {
+ oCN.RunProc("update Xt_AccountPeriod set HEndFlag=0 Where HYear =" + HYear + " and HPeriod=" + HPeriod, ref DBUtility.ClsPub.sExeReturnInfo);
+ }
+ //涓昏〃
+
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶇粨璐︽垚鍔燂紒";
+ //objJsonResult.data = null;
+ return objJsonResult;
}
catch (Exception e)
{
@@ -67,7 +245,153 @@
}
+ /// <summary>
+ /// 缁撹处鑾峰彇鏈�鍚庝竴娆$粨璐︽椂闂�
+ /// </summary>
+ /// <param name="sWhere"></param>
+ /// <returns></returns>
+ [Route("Xt_AccountPeriod/Lastlist")]
+ [HttpGet]
+ public object Lastlist()
+ {
+ try
+ {
+ //褰搇astYear=2024 lastPeriod=1鏄�,瑕佽幏鍙栦笂骞存渶鍚庝竴鏈堢殑鏃堕棿 fistYear fistPeriod
+ string lastYear = "";
+ string lastPeriod = "";
+ string fistYear = "";
+ string fistPeriod = "";
+ List<object> columnNameList = new List<object>();
- //
+ ds = oCN.RunProcReturn("select top 1 * from h_v_Xt_AccountPeriodList where 鏄惁缁撹处 = '鏄�' Order by 寮�濮嬫棩鏈� DESC", "h_v_Xt_AccountPeriodList");
+
+ //鑾峰彇瑕佺粨璐︾殑骞存湀
+ if (ds.Tables[0].Rows[0]["浼氳鏈堜唤"].ToString()=="1")
+ {
+ fistYear = (Int64.Parse(ds.Tables[0].Rows[0]["浼氳骞翠唤"].ToString()) - 1).ToString();
+ fistPeriod = (Int64.Parse(ds.Tables[0].Rows[0]["浼氳鏈堜唤"].ToString()) + 11).ToString();
+ }
+ else
+ {
+ lastYear = ds.Tables[0].Rows[0]["浼氳骞翠唤"].ToString();
+ lastPeriod = ds.Tables[0].Rows[0]["浼氳鏈堜唤"].ToString();
+ }
+
+ DateTime lastEndDate = (DateTime)ds.Tables[0].Rows[0]["缁撴潫鏃ユ湡"];
+
+ // 璁$畻瑕佺粨璐︾殑淇℃伅
+ DateTime nextBeginDate = lastEndDate.AddDays(1);
+ DateTime nextEndDate = nextBeginDate.AddMonths(1).AddDays(-1);
+
+ ds = oCN.RunProcReturn("select COUNT(*) 鏈鏍� from Kf_ICStockBillMain where HChecker ='' and HDate >='" + nextBeginDate + "' and HDate <='" + nextEndDate + "' ", "Kf_ICStockBillMain");
+ if (ds.Tables[0].Rows[0]["鏈鏍�"].ToString() == "0")
+ {
+ if (fistYear=="")
+ {
+ //鏌ヨ涓婃湀姣忎釜浠撳簱,浠撲綅,鐗╂枡鎵�鏁伴噺澶氬皯,鏍规嵁涓婃湀鏁伴噺+鏈湀杩涘叆鏀嚭鏁伴噺,鎻掑叆鏈熷垵搴撳瓨琛�
+ string sql = "SELECT b.HWHID AS 浠撳簱, b.HSPID AS 浠撲綅,b.HMaterID AS 鐗╂枡," +
+ "SUM(CASE WHEN a.HYear = '" + lastYear + "' AND a.HPeriod = '" + lastPeriod + "' THEN b.HQty ELSE 0 END) AS 鏈熷垵," +
+ "SUM(CASE WHEN a.HYear = '" + lastYear + "' AND a.HPeriod = '" + lastPeriod + "' THEN b.HQty ELSE 0 END) AS 鏈湡, " +
+ "SUM(CASE WHEN a.HYear = '" + lastYear + "' AND (a.HPeriod = '" + lastPeriod + "' OR a.HPeriod = '" + lastPeriod + "') THEN b.HQty ELSE 0 END) AS 鎬昏 " +
+ "FROM Kf_ICStockBillMain a INNER JOIN Kf_ICStockBillSub b ON a.HInterID = b.HInterID WHERE a.HYear = '" + lastYear + "' AND (a.HPeriod = '" + lastPeriod + "' OR a.HPeriod = '" + lastPeriod + "') " +
+ "GROUP BY b.HWHID,b.HSPID,b.HMaterID ORDER BY b.HWHID,b.HSPID,b.HMaterID";
+ ds = oCN.RunProcReturn(sql, "Kf_ICStockBillMain");
+
+ DataTable dt = ds.Tables[0];
+ List<Kf_ICInvBal> stockBillItemList = new List<Kf_ICInvBal>();
+
+ foreach (DataRow row in dt.Rows)
+ {
+ Kf_ICInvBal item = new Kf_ICInvBal();
+
+ item.HYear = lastYear;
+ item.HPeriod = lastPeriod;
+ item.HWhID = Convert.ToInt32(row["浠撳簱"]);
+ item.HSPID = Convert.ToInt32(row["浠撲綅"]);
+ item.HMaterID = Convert.ToInt32(row["鐗╂枡"]);
+ item.HBeginQty = Convert.ToDecimal(row["鎬昏"]);
+
+ oCN.RunProc("INSERT INTO Kf_ICInvBal (HYear, HPeriod, HWhID, HSPID, HMaterID, HBeginQty) VALUES('"+ item.HYear + "', '" + item.HPeriod + "', '" + item.HWhID + "', '" + item.HSPID + "', '" + item.HMaterID + "', '" + item.HBeginQty + "')");
+ }
+
+ // 鐜板湪stockBillItemList鍖呭惈浜嗕粠DataTable涓鍙栧苟澶勭悊杩囩殑鏁版嵁
+ }
+
+ else
+ {
+ //鏌ヨ涓婃湀姣忎釜浠撳簱,浠撲綅,鐗╂枡鎵�鏁伴噺澶氬皯,鏍规嵁涓婃湀鏁伴噺+鏈湀杩涘叆鏀嚭鏁伴噺,鎻掑叆鏈熷垵搴撳瓨琛�
+ string sql = "SELECT b.HWHID AS 浠撳簱, b.HSPID AS 浠撲綅,b.HMaterID AS 鐗╂枡," +
+ "SUM(CASE WHEN a.HYear = '" + fistYear + "' AND a.HPeriod = '" + fistPeriod + "' THEN b.HQty ELSE 0 END) AS 鏈熷垵," +
+ "SUM(CASE WHEN a.HYear = '" + lastYear + "' AND a.HPeriod = '" + lastPeriod + "' THEN b.HQty ELSE 0 END) AS 鏈湡, " +
+ "SUM(CASE WHEN (a.HYear = '" + fistYear + "' AND a.HPeriod = '" + fistPeriod + "') OR (a.HYear = '" + lastYear + "' AND a.HPeriod = '" + lastPeriod + "') THEN b.HQty ELSE 0 END) AS 鎬昏 " +
+ "FROM Kf_ICStockBillMain a INNER JOIN Kf_ICStockBillSub b ON a.HInterID = b.HInterID WHERE (a.HYear = '" + fistYear + "' AND a.HPeriod = '" + fistPeriod + "') OR (a.HYear = '" + lastYear + "' AND a.HPeriod = '" + lastPeriod + "') " +
+ "GROUP BY b.HWHID,b.HSPID,b.HMaterID ORDER BY b.HWHID,b.HSPID,b.HMaterID";
+ ds = oCN.RunProcReturn(sql, "Kf_ICStockBillMain");
+ DataTable dt = ds.Tables[0];
+ List<Kf_ICInvBal> stockBillItemList = new List<Kf_ICInvBal>();
+
+ foreach (DataRow row in dt.Rows)
+ {
+ Kf_ICInvBal item = new Kf_ICInvBal();
+
+ item.HYear = fistYear;
+ item.HPeriod = fistPeriod;
+ item.HWhID = Convert.ToInt32(row["浠撳簱"]);
+ item.HSPID = Convert.ToInt32(row["浠撲綅"]);
+ item.HMaterID = Convert.ToInt32(row["鐗╂枡"]);
+ item.HBeginQty = Convert.ToDecimal(row["鎬昏"]);
+
+ oCN.RunProc("INSERT INTO Kf_ICInvBal (HYear, HPeriod, HWhID, HSPID, HMaterID, HBeginQty) VALUES('" + item.HYear + "', '" + item.HPeriod + "', '" + item.HWhID + "', '" + item.HSPID + "', '" + item.HMaterID + "', '" + item.HBeginQty + "')");
+ }
+ }
+
+
+ //鏌ヨ瑕佺粨璐︾殑鏃ユ湡
+ ds = oCN.RunProcReturn("select top 1 * from h_v_Xt_AccountPeriodList where 鏄惁缁撹处 = '鏄�' Order by 寮�濮嬫棩鏈� DESC", "h_v_Xt_AccountPeriodList");
+ //娣诲姞鍒楀悕
+ 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;
+ }
+ 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;
+ }
+ }
+
+
+ public class Kf_ICInvBal
+ {
+ public string HYear; //浼氳骞�
+ public string HPeriod; //浼氳鏈�
+ public int HWhID; //浠撳簱鍐呯爜
+ public int HSPID; //浠撲綅鍐呯爜
+ public int HMaterID; //鐗╂枡鍐呯爜
+ public decimal HBeginQty; //鏈熷垵鏁伴噺
+ }
+
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1