From 9b4915b7b3669ffe80774740bd06c547ece49494 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 31 三月 2025 12:47:27 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormImportController.cs | 121 ++++++++++++++++++++++++++++++---------
1 files changed, 92 insertions(+), 29 deletions(-)
diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
index fe71185..c3e0626 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
@@ -9,7 +9,7 @@
using System.Web.Http;
using System.Web.Script.Serialization;
using WebAPI.Models;
-
+using System.Globalization;
namespace WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�
{
public class JIT_DayPlanPlatFormImportController : ApiController
@@ -20,6 +20,8 @@
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
public static string BillType = "4610";
Sc_WorkBillSortBillMain omdelMian = new Sc_WorkBillSortBillMain();
+ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+
#region 鐢熶骇鏃ヨ鍒� 鏂囦欢涓婁紶
[Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_DR")]
@@ -61,16 +63,45 @@
tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//鐢熶骇璁㈠崟涓籭d
tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//鐢熶骇璁㈠崟瀛恑d
tb2.Columns.Add("HProdORGID", typeof(Int32));//缁勭粐id
+ tb2.Columns.Add("HSeOrderBillNo", typeof(string));//閿�鍞鍗曞彿
+ //鑾峰彇绯荤粺鍙傛暟
+ string Ret = "";
+ oSystemParameter.ShowBill(ref Ret);
+
+ LogService.Write("excel鍊硷細" + ExcelDs.Tables[0].Rows[1][15].ToString());//2024-11-26
//娣诲姞鏁版嵁
for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
- {
+ {
DataRow row = tb2.NewRow();
for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
{
row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
}
- tb2.Rows.Add(row);
+ //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+ if (ExcelDs.Tables[0].Rows[i][0].ToString() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "")
+ {
+ continue;
+ }
+ //else if (oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "0" && oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "")
+ //{
+ // Int32 HDays = Convert.ToInt32(oSystemParameter.omodel.JIT_DayPlan_TimeFrame) * 7;
+
+
+
+
+ // for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+ // {
+ // if (Convert.ToInt32(ExcelDs.Tables[0].Rows[i][j].ToString()) > 0 )
+ // {
+ // continue;
+ // }
+ // }
+ //}
+ else
+ {
+ tb2.Rows.Add(row);
+ }
}
var error = "";
@@ -101,9 +132,9 @@
return objJsonResult;
}
- string sql1 = string.Format("select * from h_v_IF_ICMOBillList where 鍗曟嵁鍙�='{0}' and 鐢熶骇杞﹂棿浠g爜='{1}' and 浜у搧浠g爜='{2}' and 鏄庣粏琛屽彿={3} ",
+ string sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where 鍗曟嵁鍙�='{0}' and 鐢熶骇杞﹂棿浠g爜='{1}' and 浜у搧浠g爜='{2}' and 鏄庣粏琛屽彿={3} ",
tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString(), tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString(), tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString(), tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString());
- ds = oCN.RunProcReturn(sql1, "h_v_IF_ICMOBillList");
+ ds = oCN.RunProcReturn(sql1, "h_v_JIT_ICMOBillList_DR");
if (ds.Tables[0].Rows.Count == 0)
{
@@ -127,13 +158,22 @@
tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HDeptID"].ToString();
tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//鐢熶骇璁㈠崟涓籭d
tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//鐢熶骇璁㈠崟瀛恑d
- tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺
+ string sErr = "";
+ if (oSystemParameter.ShowBill(ref sErr))
+ {
+ if (oSystemParameter.omodel.WMS_CampanyName != "瀹濆伐")
+ {
+ tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺
+ }
+ }
+ //tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺
+ tb2.Rows[i]["HSeOrderBillNo"] = ds.Tables[0].Rows[0]["閿�鍞鍗曞彿"].ToString();//閿�鍞鍗曞彿
}
- ds = oCN.RunProcReturn("select * from h_v_JIT_Sc_WorkBillSortBillList " +
+ ds = oCN.RunProcReturn("select * from h_v_JIT_WorkBillSortBillList_DR " +
$"where 鐢熶骇璁㈠崟鍙�='{tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString()}' and 鐢熶骇璁㈠崟鏄庣粏琛屽彿='{tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()}' " +
$"and 鐢熶骇杞﹂棿缂栫爜='{tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString()}' and 鐗╂枡浠g爜='{tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString()}' " +
- $"and 鐢熶骇璧勬簮缂栫爜='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}' ", "h_v_JIT_Sc_WorkBillSortBillList");
+ $"and 鐢熶骇璧勬簮缂栫爜='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}' ", "h_v_JIT_WorkBillSortBillList_DR");
//缁勭粐缂栫爜='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}' and
//and 鐢熶骇璧勬簮缂栫爜='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'
@@ -155,7 +195,7 @@
else
{
//鍛樺伐
- ds = oCN.RunProcReturn($"select * from Gy_Employee where HNumber='{tb2.Rows[i]["鍛樺伐缂栫爜"].ToString()}'", "Gy_Employee");
+ ds = oCN.RunProcReturn($"select * from Gy_Employee with(nolock) where HNumber='{tb2.Rows[i]["鍛樺伐缂栫爜"].ToString()}'", "Gy_Employee");
if (ds.Tables[0].Rows.Count > 0) {
tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
tb2.Rows[i]["鍛樺伐"] = ds.Tables[0].Rows[0]["HName"].ToString();
@@ -170,7 +210,7 @@
}
//璁¢噺鍗曚綅
- ds = oCN.RunProcReturn($"select * from Gy_Unit where HNumber='{tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()}'", "Gy_Unit");
+ ds = oCN.RunProcReturn($"select * from Gy_Unit with(nolock) where HNumber='{tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()}'", "Gy_Unit");
if (ds.Tables[0].Rows.Count > 0)
{
tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
@@ -185,7 +225,7 @@
}
//鐢熶骇璧勬簮
- ds = oCN.RunProcReturn($"select * from Gy_Source where HNumber='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'", "Gy_Source");
+ ds = oCN.RunProcReturn($"select * from Gy_Source with(nolock) where HNumber='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'", "Gy_Source");
if (ds.Tables[0].Rows.Count > 0)
{
tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
@@ -199,7 +239,7 @@
}
}
//缁勭粐
- ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS where HNumber='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}'", "Xt_ORGANIZATIONS");
+ ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS with(nolock) where HNumber='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}'", "Xt_ORGANIZATIONS");
if (ds.Tables[0].Rows.Count > 0)
{
tb2.Rows[i]["HProdORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
@@ -293,10 +333,11 @@
}
- int TrueCount = 0, SumCount = 0;
+
for (int i = 0; i < list.Count; i++)
{
+ int TrueCount = 0, SumCount = 0;
long HInterID = 0;
var HBillNo = "";
if (list[i]["鍗曟嵁鍙�"].ToString() == "" && list[i]["hmainid"].ToString() == "")
@@ -308,6 +349,7 @@
var HProdORGID = list[i]["HProdORGID"].ToString();
var HWorkShopID = list[i]["HWorkShopID"].ToString();
var HSourceID = list[i]["HSourceID"].ToString();
+ var HWorkQty = DBUtility.ClsPub.isDoule(list[i]["浜ц兘"]);
var HYX = list[i]["浼樺厛绾�"].ToString();
var HEmpID = list[i]["HEmpID"].ToString();
var HMaterID = list[i]["HMaterID"].ToString();
@@ -322,9 +364,12 @@
var HDate = omdelMian.HDate;
var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString();
var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString();
+ var HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString();
- ds = oCN.RunProcReturn($"select * from Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
- $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
+ string sql = $"select * from Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+ $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}";
+ LogService.Write("sql:" + sql);
+ ds = oCN.RunProcReturn(sql, "Sc_WorkBillSortBillMain");
if (ds.Tables[0].Rows.Count > 0)
{
objJsonResult.code = "0";
@@ -337,22 +382,40 @@
//涓昏〃
oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," +
"HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," +
- "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HEmpID," +
+ "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," +
" HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
" HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
- "HMainSourceInterID,HMainSourceEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec)values" +
+ "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" +
+ ",HSeOrderBillNo)values" +
$"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
$"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," +
- $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
+ $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
$" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," +
$" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," +
- $" {HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID})");
+ $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" +
+ $",'{HSeOrderBillNo}')");
}
int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;
+ // 缁熻鎬诲ぉ鏁�
+ HashSet<DateTime> uniqueDates = new HashSet<DateTime>();
+
+ foreach (var key in list[i].Keys)
+ {
+ if (DateTime.TryParseExact(key, "yyyy-M-d", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
+ {
+ uniqueDates.Add(date);
+ }
+ }
+
+ SumDay = uniqueDates.Count;
+
+
for (int j = 0; j < SumDay; j++)
{
+ LogService.Write("1:" + list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString());
+ LogService.Write("2:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd"));
//涓昏〃瀛愯〃閮芥湁鏁版嵁
if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "")
{
@@ -369,21 +432,22 @@
}
}
//涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
- if (j == 30 && SumCount == 0 && HInterID != 0 && HBillNo != "")
+ if (j == SumDay - 1 && SumCount == 0 && HInterID != 0 && HBillNo != "")
{
objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0);
}
}
+ if (TrueCount != SumCount)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = objJsonResult.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
}
- if (TrueCount != SumCount)
- {
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = objJsonResult.Message;
- objJsonResult.data = null;
- return objJsonResult;
- }
+
objJsonResult.code = "1";
objJsonResult.count = 1;
@@ -405,7 +469,6 @@
{
//鑾峰彇琛ㄦ牸鏁版嵁
ds = oCN.RunProcReturn($"select * from h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList");
-
int count = 0;
if (ds.Tables[0].Rows.Count > 0)
{
--
Gitblit v1.9.1