From 00e25e4a9c9bd2fc91558c3c1a68f47db6d08b1d Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 08 七月 2024 18:57:35 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs | 219 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 194 insertions(+), 25 deletions(-)
diff --git a/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs b/WebAPI/Controllers/BLL/Xt_AccountPeriodController.cs
index ce0b655..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,32 @@
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
- {
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "Sucess锛�";
- objJsonResult.data = ds.Tables[0];
- return objJsonResult;
- }
+
+ //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)
{
@@ -154,7 +167,7 @@
long HPeriod = list[0].HPeriod;
DateTime HBeginDate = list[0].HBeginDate;
DateTime HEndDate = list[0].HEndDate;
- string HEndFlag = list[0].HEndFlag;
+ string HEndFlag = "1";
@@ -169,14 +182,14 @@
"(HYear,HPeriod,HBeginDate,HEndDate" +
",HEndFlag" +
") " +
- " values(" + HYear + "," + HPeriod + "," + HBeginDate + "," + HEndDate +
- ",'" + HEndFlag + "'" +
+ " values('" + HYear + "','" + HPeriod + "','" + HBeginDate + "','" + HEndDate +
+ "','" + HEndFlag + "'" +
") ");
//淇敼涓婄骇涓洪潪鏈骇浠g爜
oCN.Commit();
objJsonResult.code = "1";
objJsonResult.count = 1;
- objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+ objJsonResult.Message = "缁撹处鎴愬姛锛�";
//objJsonResult.data = null;
return objJsonResult;
}
@@ -192,24 +205,32 @@
}
/// <summary>
- /// 浼氳鏈熼棿鍒楄〃鍒犻櫎鎸夐挳
+ /// 浼氳鏈熼棿鍒楄〃鍙嶇粨璐︽寜閽�
///鍙傛暟锛歴tring sql銆�
///杩斿洖鍊硷細object銆�
/// </summary>
- [Route("Xt_AccountPeriod/Delete_Json")]
+ [Route("Xt_AccountPeriod/Update_Json")]
[HttpGet]
- public object Delete_Json(long HYaer,long HPeriod)
+ public object Update_Json(long HYear, long HPeriod ,string num)
{
try
{
//鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
oCN.BeginTran();
+ if (num=="1")//缁撹处
+ {
+ 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.RunProc("delete from Xt_AccountPeriod Where HYaer =" + HYaer + " and HPeriod=" + HPeriod, ref DBUtility.ClsPub.sExeReturnInfo);
+
oCN.Commit();
objJsonResult.code = "1";
objJsonResult.count = 1;
- objJsonResult.Message = "鍒犻櫎鍗曟嵁鎴愬姛锛�";
+ objJsonResult.Message = "鍙嶇粨璐︽垚鍔燂紒";
//objJsonResult.data = null;
return objJsonResult;
}
@@ -223,6 +244,154 @@
}
}
- //
+
+ /// <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