From 3850c75709556da9f0234d2d882148d93787e77f Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期五, 10 三月 2023 13:48:44 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/博日自动扫码线/ScanlineAPIController.cs | 103 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 76 insertions(+), 27 deletions(-)
diff --git "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
index 705ef1a..520edd5 100644
--- "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
+++ "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs"
@@ -9,6 +9,7 @@
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;
+using ViewAPI;
using WebAPI.Models;
namespace WebAPI.Controllers.鍗氭棩鑷姩鎵爜绾�
@@ -44,9 +45,9 @@
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
sDay = sDay.Substring(sDay.Length - 2, 2);
- string sTMNumber ="ZX"+ sYear + sPeriod + sDay;
+ string sTMNumber = "ZX" + sYear + sPeriod + sDay;
ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //鑾峰彇鏈�澶ф祦姘村彿
- int LSH = ClsPub.isInt(ds.Tables[0].Rows[0][0])+1; //娴佹按鍙峰姞1
+ int LSH = ClsPub.isInt(ds.Tables[0].Rows[0][0]) + 1; //娴佹按鍙峰姞1
string TM = sTMNumber + LSH;
jsn.packagebarcode = TM;
oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
@@ -54,14 +55,15 @@
}
objJsonResult.status = 0;
objJsonResult.msg = "鏌ヨ鏁版嵁鎴愬姛锛�";
- objJsonResult.data =objJsonResult.data;
+ objJsonResult.data = objJsonResult.data;
return objJsonResult;
}
catch (Exception e)
{
- objJsonResult.status =-1;
+ LogService.Write("閿欒锛�" + e.Message.ToString());
+ objJsonResult.status = -1;
objJsonResult.msg = "鐢熸垚绠辨潯鐮佸け璐ワ紒";
- objJsonResult.data =null;
+ objJsonResult.data = null;
return objJsonResult;
}
}
@@ -74,37 +76,50 @@
{
try
{
+ Log.LogInfo(msg.ToString()); //璁板綍鎻愪氦鏁版嵁
JavaScriptSerializer js = new JavaScriptSerializer(); //瀹炰緥鍖栦竴涓兘澶熷簭鍒楀寲鏁版嵁鐨勭被
ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString()); //灏唈son鏁版嵁杞寲涓哄璞$被鍨嬪苟璧嬪�肩粰list
if (list.billno != "" && list.billno != null) //浠诲姟鍗曞彿锛岄潪蹇呴』锛岄潪绌哄垯鏍¢獙barcodes閲宐arcode鏄惁鐢辨浠诲姟鍗曞埗浣滅敓鎴愮殑
{
- ds = oCN.RunProcReturn("Select HBarCode barcode from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim()+"' Order by HItemID ", "Gy_BarCodeBill");
+ ds = oCN.RunProcReturn("Select HBarCode barcode,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' Order by HItemID ", "Gy_BarCodeBill");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
+ LogService.Write("褰撳墠璁㈠崟鏃犵粦瀹氭潯鐮�");
objJsonResult.status = -1;
objJsonResult.msg = "褰撳墠璁㈠崟鏃犵粦瀹氭潯鐮�!";
objJsonResult.data = null;
return objJsonResult;
}
List<string> NameList = (from r in ds.Tables[0].AsEnumerable() select r.Field<string>("barcode")).ToList();
- List<string> NameList1= list.barcodes.Select(t => t.barcode).ToList();
+ List<string> NameList1 = list.barcodes.Select(t => t.barcode).ToList();
var strList = NameList1.Except(NameList).ToList(); //鍒ゆ柇鎻愪氦鏁版嵁涓潯鐮佹槸鍚﹀瓨鍦ㄤ簬璁㈠崟涓�
- if (strList.Count > 0)
+ if (strList.Count > 0)
{
- string Str=String.Join(",", strList.ToArray());
+ string Str = String.Join(",", strList.ToArray());
+ LogService.Write("鏉$爜:" + Str.ToString() + " 涓嶅寘鍚湪璁㈠崟:" + list.billno + "涓�!");
objJsonResult.status = -1;
- objJsonResult.msg = "鏉$爜:"+ Str.ToString()+" 涓嶅寘鍚湪璁㈠崟:"+list.billno+"涓�!";
+ objJsonResult.msg = "鏉$爜:" + Str.ToString() + " 涓嶅寘鍚湪璁㈠崟:" + list.billno + "涓�!";
objJsonResult.data = null;
return objJsonResult;
- }
+ }
}
DLL.ClsSc_PackUnionBill oBill = new DLL.ClsSc_PackUnionBill();
//鍒ゆ柇绠辩爜鏄惁瀛樺湪
bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode);
- if (IsBarCodePack == false)
+ if (IsBarCodePack == false)
{
+ LogService.Write($"绠辩爜:{list.packagebarcode}宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�");
objJsonResult.status = -1;
- objJsonResult.msg = "绠辩爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+ objJsonResult.msg = $"绠辩爜:{list.packagebarcode}宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ ds = oCN.RunProcReturn("Select * from Gy_BarCodeBill where HBarCode='" + list.packagebarcode.ToString().Trim() + "' and HStopflag='1'", "Gy_BarCodeBill");
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ LogService.Write("姝ょ鏉$爜宸蹭綔搴�");
+ objJsonResult.status = -1;
+ objJsonResult.msg = "姝ょ鏉$爜宸蹭綔搴�";
objJsonResult.data = null;
return objJsonResult;
}
@@ -114,13 +129,13 @@
oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
oItem.HBillType = "3783";
oItem.HBillSubType = "3783";
- oItem.HDate= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
+ oItem.HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
oItem.HBillNo = DBUtility.ClsPub.CreateBillCode(oItem.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
oItem.HBillStatus = 1;
oItem.HCheckItemNowID = 0;
oItem.HCheckItemNextID = 0;
oItem.HCheckFlowID = 0;
- oItem.HRemark = "鑷姩鍖呰绾跨敓杈扮鏉$爜";
+ oItem.HRemark = "鑷姩鍖呰绾跨敓鎴愮鏉$爜";
oItem.HBacker = "";
oItem.HBackDate = "";
oItem.HMaker = "";
@@ -136,32 +151,33 @@
oItem.HDeleteDate = "";
oItem.HICMOInterID = 0;
oItem.HICMOBillNo = "";
- oItem.HBarCode_Pack= list.packagebarcode;
+ oItem.HBarCode_Pack = list.packagebarcode;
oItem.HMaterID = 0;
oItem.HUnitID = 0;
- oItem.HUseFlag =false; //鏈夋晥鐘舵��
+ oItem.HUseFlag = false; //鏈夋晥鐘舵��
oBill.omodel = oItem;
for (int i = 0; i < list.barcodes.Count; i++)
{
//鍒ゆ柇鏉$爜鏄惁瀛樺湪
- bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode);
- if (IsBarCodePack == false)
+ bool IsBarCode = oBill.IsBarCode(list.barcodes[i].barcode);
+ if (IsBarCode == false)
{
+ DataTable dt = oCN.RunProcReturn("Select HBarCode_Pack from Sc_PackUnionBillSub Where HBarCode='" + list.barcodes[i].barcode + "'", "Sc_PackUnionBillSub").Tables[0];
objJsonResult.status = -1;
- objJsonResult.msg = "鏉$爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�";
+ objJsonResult.msg = $"鏉$爜锛歿list.barcodes[i].barcode}锛屽凡瀛樺湪绠辩爜锛歿dt.Rows[0]["HBarCode_Pack"]}涓紝鏈缁戝畾绠辩爜涓猴細{list.packagebarcode},缁戝畾澶辫触,涓嶈兘閲嶅缁戝畾锛�";
objJsonResult.data = null;
return objJsonResult;
}
Models.ClsSc_PackUnionBillSub oItemSub = new ClsSc_PackUnionBillSub();
ds0 = oCN.RunProcReturn("Select HBarCode,HMaterID,HUnitID,HQty,HSourceID,HGroupID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' and HBarCode='" + list.barcodes[i].barcode + "' Order by HItemID ", "Gy_BarCodeBill");
- oItemSub.HEntryID = i+1;
+ oItemSub.HEntryID = i + 1;
oItemSub.HMaterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HMaterID"].ToString());
oItemSub.HUnitID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HUnitID"].ToString());
oItemSub.HQty = DBUtility.ClsPub.isDoule(ds0.Tables[0].Rows[0]["HQty"].ToString());
oItemSub.HSourceID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceID"].ToString());
oItemSub.HEquipID = 0;
oItemSub.HGroupID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HGroupID"].ToString());
- oItemSub.HWorkerID = 0;
+ oItemSub.HWorkerID = 0;
oItemSub.HBarCode = list.barcodes[i].barcode;
oItemSub.HBarCode_Pack = list.packagebarcode;
oItemSub.HCloseMan = "";
@@ -189,6 +205,8 @@
}
if (bResult)
{
+ LogService.Write("鎻愪氦鎴愬姛绠辨潯鐮侊細" + list.packagebarcode);
+ Log.LogSaveInfo("鎻愪氦鎴愬姛绠辨潯鐮侊細" + list.packagebarcode); //璁板綍鎻愪氦鏁版嵁
objJsonResult.status = 0;
objJsonResult.msg = "success";
objJsonResult.data = null;
@@ -196,6 +214,7 @@
}
else
{
+ LogService.Write("淇濆瓨澶辫触锛�" +DBUtility.ClsPub.sExeReturnInfo);
objJsonResult.status = -1;
objJsonResult.msg = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
objJsonResult.data = null;
@@ -204,7 +223,8 @@
}
catch (Exception e)
{
- objJsonResult.status =-1;
+ LogService.Write("绠辨潯鐮佺粦瀹氬叧绯绘彁浜ゆ帴鍙� 鎶涘嚭寮傚父" + e.Message.ToString());
+ objJsonResult.status = -1;
objJsonResult.msg = e.Message;
objJsonResult.data = null;
return objJsonResult;
@@ -219,14 +239,43 @@
{
try
{
+ //鍒ゆ柇鏄惁鍏ュ簱
+ ds = oCN.RunProcReturn("select * from Sc_ScanLineInStock where HBarCode_Pack='" + packagebarcode + "'", "Sc_ScanLineInStock");
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ objJsonResult.status = -1;
+ objJsonResult.msg = "璇ョ鏉$爜宸插叆搴撲笉鍏佽鍙栨秷!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("Select 1 from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "'", "Gy_BarCodeBill");
+ if (ds == null && ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.status = -1;
+ objJsonResult.msg = "鏃犳晥绠辨潯鐮�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ ds = oCN.RunProcReturn("Select 1 from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "' and HStopflag='1'", "Gy_BarCodeBill");
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ objJsonResult.status = -1;
+ objJsonResult.msg = "姝ょ鏉$爜宸蹭綔搴�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
//
oCN.BeginTran();
+ //鍒犻櫎SUM涓昏〃
+ oCN.RunProc("Delete From Sc_PackUnionBillSub_Sum where HBarCode_Pack='" + packagebarcode.ToString() + "'");
//鍒犻櫎瀛愯〃
- oCN.RunProc("Delete From Sc_PackUnionBillSub where HBarCode_Pack=" + packagebarcode.ToString());
+ oCN.RunProc("Delete From Sc_PackUnionBillSub where HBarCode_Pack='" + packagebarcode.ToString() + "'");
//鍒犻櫎涓昏〃
- oCN.RunProc("Delete From Sc_PackUnionBillMain where HBarCode_Pack=" + packagebarcode.ToString());
+ oCN.RunProc("Delete From Sc_PackUnionBillMain where HBarCode_Pack='" + packagebarcode.ToString() + "'");
//浣滃簾鏉$爜妗f琛�
- oCN.RunProc("Update Gy_BarCodeBill set HStopflag='1' where HBarCode=" + packagebarcode.ToString());
+ oCN.RunProc("Update Gy_BarCodeBill set HStopflag='1' where HBarCode='" + packagebarcode.ToString() + "'");
oCN.Commit();
@@ -256,7 +305,7 @@
//string aa=list.getWeek(Convert.ToDateTime(tim));
string aa = list.GetCodeDateStr(Convert.ToDateTime(tim));
objJsonResult.status = 0;
- objJsonResult.msg =aa.ToString();
+ objJsonResult.msg = aa.ToString();
objJsonResult.data = null;
return objJsonResult;
}
--
Gitblit v1.9.1