From 9d1960d3041695b470e0db44de914012ef3a8a2f Mon Sep 17 00:00:00 2001
From: ouyangqing <ouyangqing@DESKTOP-B85SG1D>
Date: 星期四, 21 一月 2021 17:14:49 +0800
Subject: [PATCH] 进出站单限制
---
WebAPI/Service/YqnQbService.cs | 76 ++++++++++++++++++-------
WebAPI/Service/YqnDal.cs | 48 +++++++++++----
WebAPI/Controllers/NewApiController.cs | 4
3 files changed, 91 insertions(+), 37 deletions(-)
diff --git a/WebAPI/Controllers/NewApiController.cs b/WebAPI/Controllers/NewApiController.cs
index eff6c61..db83415 100644
--- a/WebAPI/Controllers/NewApiController.cs
+++ b/WebAPI/Controllers/NewApiController.cs
@@ -17,9 +17,9 @@
/// <returns></returns>
[Route("api/newBill/getNewInterBillNo")]
[HttpGet]
- public ApiResult<DocumentsView> GetNewInterBillNo()
+ public ApiResult<DocumentsView> GetNewInterBillNo(string billType)
{
- var model = YqnQbService.GetInterBillNo();
+ var model = YqnQbService.GetInterBillNo(billType);
return model;
}
/// <summary>
diff --git a/WebAPI/Service/YqnDal.cs b/WebAPI/Service/YqnDal.cs
index e60f7ee..3576bf2 100644
--- a/WebAPI/Service/YqnDal.cs
+++ b/WebAPI/Service/YqnDal.cs
@@ -10,38 +10,58 @@
public class YqnDal
{
/// <summary>
- /// 鏍规嵁鍗曟嵁鍙锋垨鑰呮祦杞崱鏌ユ壘杩涚珯鍗�
+ /// 鏍规嵁宸ュ簭鍜屾祦杞崱鏌ユ壘杩涚珯鍗�
/// </summary>
/// <param name="billNo"></param>
/// <param name="icmoBillNo"></param>
/// <returns></returns>
- public static Models.M_StationBillMail GetStationInBillMail(string billNo, string icmoBillNo)
+ public static Models.M_StationBillMail GetStationInBillMail(long hProcID, string icmoBillNo)
{
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append("select top 1 HBillType,HInterID,HDate,HBillNo,HICMOBillNo,HEmpID,HProcID from Sc_StationInBillMain where HBillType='3790' ");
- if (!string.IsNullOrEmpty(billNo))
- sqlBuilder.Append(" and HBillNo=@billNo ");
- if (!string.IsNullOrEmpty(icmoBillNo))
- sqlBuilder.Append(" and HICMOBillNo=@icmoBillNo");
- var model = SqlPools.GetInstance("YqnConn").GetModel<Models.M_StationBillMail>(sqlBuilder.ToString(), new { billNo, icmoBillNo });
+ sqlBuilder.Append(" and HICMOBillNo=@icmoBillNo ");
+ sqlBuilder.Append(" and HProcID=@hProcID");
+ var model = SqlPools.GetInstance("YqnConn").GetModel<Models.M_StationBillMail>(sqlBuilder.ToString(), new { icmoBillNo,hProcID });
return model;
}
/// <summary>
- /// 鏍规嵁鍗曟嵁鍙锋垨鑰呮祦杞崱鏌ユ壘鍑虹珯鍗�
+ /// 鏍规嵁宸ュ簭鍜屾祦杞崱鏌ユ壘鍑虹珯鍗�
/// </summary>
/// <param name="billNo"></param>
/// <param name="icmoBillNo"></param>
/// <returns></returns>
- public static Models.M_StationBillMail GetStationOutBillMail(string billNo, string icmoBillNo)
+ public static Models.M_StationBillMail GetStationOutBillMail(long hProcID, string icmoBillNo)
{
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append("select top 1 HBillType,HInterID,HDate,HBillNo,HICMOBillNo,HEmpID,HProcID from Sc_StationOutBillMain where HBillType in ('3791','4788') ");
- if (!string.IsNullOrEmpty(billNo))
- sqlBuilder.Append(" and HBillNo=@billNo ");
- if (!string.IsNullOrEmpty(icmoBillNo))
- sqlBuilder.Append(" and HICMOBillNo=@icmoBillNo");
- var model = SqlPools.GetInstance("YqnConn").GetModel<Models.M_StationBillMail>(sqlBuilder.ToString(), new { billNo, icmoBillNo });
+ sqlBuilder.Append(" and HICMOBillNo=@icmoBillNo ");
+ sqlBuilder.Append(" and HProcID=@hProcID");
+ var model = SqlPools.GetInstance("YqnConn").GetModel<Models.M_StationBillMail>(sqlBuilder.ToString(), new { icmoBillNo, hProcID });
return model;
}
+ /// <summary>
+ /// 鏍规嵁娴佷紶鍗″彿鑾峰彇杩涚珯鍗曞垪琛�
+ /// </summary>
+ /// <param name="icBillNo"></param>
+ /// <returns></returns>
+ public static List<Models.M_StationBillMail> GetStationInBillMailList(string icBillNo)
+ {
+ StringBuilder sqlBuilder = new StringBuilder();
+ sqlBuilder.Append("select HBillType,HInterID,HDate,HBillNo,HICMOBillNo,HEmpID,HProcID from Sc_StationInBillMain where HBillType='3790' and HICMOBillNo=@icBillNo");
+ var list = SqlPools.GetInstance("YqnConn").GetModelList<Models.M_StationBillMail>(sqlBuilder.ToString(), new { icBillNo });
+ return list;
+ }
+ /// <summary>
+ /// 鏍规嵁娴佷紶鍗″彿鑾峰彇鍑虹珯鍗曞垪琛�
+ /// </summary>
+ /// <param name="icBillNo"></param>
+ /// <returns></returns>
+ public static List<Models.M_StationBillMail> GetStationOutBillMailList(string icBillNo)
+ {
+ StringBuilder sqlBuilder = new StringBuilder();
+ sqlBuilder.Append("select HBillType,HInterID,HDate,HBillNo,HICMOBillNo,HEmpID,HProcID from Sc_StationOutBillMain where HBillType in ('3791','4788') and HICMOBillNo=@icBillNo");
+ var list = SqlPools.GetInstance("YqnConn").GetModelList<Models.M_StationBillMail>(sqlBuilder.ToString(), new { icBillNo });
+ return list;
+ }
}
}
\ No newline at end of file
diff --git a/WebAPI/Service/YqnQbService.cs b/WebAPI/Service/YqnQbService.cs
index 9ec208b..6bbe40e 100644
--- a/WebAPI/Service/YqnQbService.cs
+++ b/WebAPI/Service/YqnQbService.cs
@@ -5,6 +5,7 @@
using System.Data;
using System.Linq;
using System.Web;
+using WebAPI.Dapper;
using WebAPI.Models;
using WebAPI.WebS;
@@ -16,10 +17,10 @@
/// 鑾峰彇鍗曟嵁鍙�
/// </summary>
/// <returns></returns>
- public static ApiResult<DocumentsView> GetInterBillNo()
+ public static ApiResult<DocumentsView> GetInterBillNo(string billType)
{
- var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
- var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+ var hInterId= DBUtility.ClsPub.CreateBillID(billType, ref DBUtility.ClsPub.sExeReturnInfo);
+ var hBillNo= DBUtility.ClsPub.CreateBillCode(billType, ref DBUtility.ClsPub.sExeReturnInfo, true);
if (hInterId == 0 || string.IsNullOrEmpty(hBillNo))
return new ApiResult<DocumentsView> { code = -1, msg = "鑾峰彇澶辫触" };
DocumentsView documentsView = new DocumentsView()
@@ -84,20 +85,53 @@
return new ApiResult<DataSet> { code = -1, msg = "鏈煡璇㈠埌宸ヤ綔涓績" };
return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
}
+ private static ConcurrentDictionary<string, string> dicLock = new System.Collections.Concurrent.ConcurrentDictionary<string, string>();//骞跺彂閿�
/// <summary>
/// 杩涚珯鎺ユ敹鍗�
/// </summary>
public static ApiResult SetStationInBill(ClsSc_StationInBillMain oMain)
{
- WebS.WebService1 oWebs = new WebS.WebService1();
- string sErrMsg = string.Empty;
- var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg);
- if (!result)
+ if (dicLock.TryAdd(oMain.HICMOBillNo + "jz", ""))//闃叉骞跺彂
+ return new ApiResult { code = -1, msg = "鏈嶅姟鍣ㄧ箒蹇�" };
+ try
{
+ if (oMain.HProcID == 0 || oMain.HQty == 0 || oMain.HEmpID == 0||string.IsNullOrEmpty(oMain.HICMOBillNo)||string.IsNullOrEmpty(oMain.HProcExchBillNo)||oMain.HQty==0||oMain.HICMOInterID==0||string.IsNullOrEmpty(oMain.HBillNo))
+ return new ApiResult { code = 1, msg = "鍙傛暟涓嶅叏" };
+ var stationInList = YqnDal.GetStationInBillMailList(oMain.HICMOBillNo);//鑾峰緱璇ユ祦杞崱鎵�鏈夎繘绔欏崟
+ if (stationInList.Count > 0)
+ {
+ var stationOutList = YqnDal.GetStationOutBillMailList(oMain.HICMOBillNo);//鑾峰緱璇ユ祦杞崱鎵�鏈夊嚭绔欏崟
+ var stationInModel = stationInList.OrderByDescending(a => a.HDate).First();//鑾峰彇杩涚珯鍗曟渶鏂拌繘绔欏伐搴�
+ if (stationOutList.Count == 0 && oMain.HEmpID == stationInModel.HEmpID)
+ return new ApiResult { code = -1, msg = "閲嶅鎵弿" };
+ if (stationOutList.Count == 0 && oMain.HEmpID != stationInModel.HEmpID)
+ return new ApiResult { code = -1, msg = "姝ゅ崟宸插叧鑱�" };
+ var stationOutModel = stationOutList.OrderByDescending(a => a.HDate).First();//鑾峰彇鍑虹珯鍗曟渶鏂板嚭绔欏伐搴�
+ if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HEmpID == oMain.HEmpID)
+ return new ApiResult { code = -1, msg = "閲嶅鎵弿" };
+ if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HEmpID == oMain.HEmpID)
+ return new ApiResult { code = -1, msg = "姝ゅ崟宸插叧鑱�" };
+ if (stationOutList.Exists(a => a.HProcID == oMain.HProcID))
+ return new ApiResult { code = -1, msg = "璇ュ崟鎹凡瀹屾垚姝ゅ伐鑹�" };
+ }
+ WebS.WebService1 oWebs = new WebS.WebService1();
+ string sErrMsg = string.Empty;
+ var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg);//杩涚珯
+ if (!result)
+ {
- return new ApiResult { code = -1, msg = sErrMsg };
+ return new ApiResult { code = -1, msg = sErrMsg };
+ }
+ return new ApiResult { code = 1, msg = "鎿嶄綔鎴愬姛" };
}
- return new ApiResult { code = 1, msg = "鎿嶄綔鎴愬姛" };
+ catch (Exception ex)
+ {
+ throw;
+ }
+ finally
+ {
+ dicLock.TryRemove(oMain.HICMOBillNo + "jz", out string key);
+ }
}
/// <summary>
/// 鑾峰彇杩涚珯鍗曞垪琛�
@@ -128,6 +162,14 @@
/// </summary>
public static ApiResult SetStationOutBill(StationOutBillView omodel)
{
+ if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo))
+ return new ApiResult { code = -1, msg = "鏈嶅姟鍣ㄧ箒蹇�" };
+ var stationInBillModel = YqnDal.GetStationInBillMail(omodel.HProcID, omodel.HICMOBillNo);
+ if (stationInBillModel == null)
+ return new ApiResult { code = -1, msg = "璇ュ伐搴忚繘绔欏崟涓嶅瓨鍦�" };
+ var stationOutBillModel = YqnDal.GetStationOutBillMail(omodel.HProcID, omodel.HICMOBillNo);
+ if (stationOutBillModel != null)
+ return new ApiResult { code = -1, msg = "璇ュ伐搴忓凡瀛樺湪鍑虹珯鍗�" };
WebS.WebService1 oWebs = new WebS.WebService1();
string sErrMsg = string.Empty;
var result = SetOutBill(omodel);
@@ -184,17 +226,14 @@
var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 宸ヤ綔涓績浠g爜,HName 宸ヤ綔涓績 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
return dataSet;
}
- private static ConcurrentDictionary<string,string> dicLock=new System.Collections.Concurrent.ConcurrentDictionary<string,string>();//骞跺彂閿�
public static ApiResult SetOutBill(StationOutBillView omodel)
{
try
{
- if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo))
- return new ApiResult { code = -1, msg = "鏈嶅姟鍣ㄧ箒蹇�" };
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
- omodel.HInterID = DBUtility.ClsPub.CreateBillID("4788", ref DBUtility.ClsPub.sExeReturnInfo);
+ omodel.HInterID = DBUtility.ClsPub.CreateBillID("3791", ref DBUtility.ClsPub.sExeReturnInfo);
oCN.BeginTran();
- var sql = "Insert Into Sc_StationOutBillMain " +
+ oCN.RunProc("Insert Into Sc_StationOutBillMain " +
"(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
",HYear,HPeriod,HRemark" +
",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
@@ -202,24 +241,19 @@
",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
",HSupID,HQty,HPrice,HMoney" +
") " +
- " values('4788','4788'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate()" +
+ " values('3791','3791'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate()" +
"," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'" +
"," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HProcPlanInterID.ToString() + "," + omodel.HProcPlanEntryID.ToString() + ",'" + omodel.HProcPlanBillNo + "'," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() +
",'" + omodel.HProcExchBillNo + "'," + omodel.HMaterID.ToString() + "," + omodel.HProcID.ToString() + "," + omodel.HICMOQty.ToString() + "," + omodel.HPlanQty.ToString() + ",getdate()," + omodel.HSourceID.ToString() +
"," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate()" +
"," + omodel.HSupID.ToString() + "," + omodel.HQty.ToString() + "," + omodel.HPrice.ToString() + "," + omodel.HMoney.ToString() +
- ") ";
- oCN.RunProc(sql);
+ ") ");
oCN.Commit();
return new ApiResult { code = 1, msg = "鏂板鎴愬姛" };
}
catch (Exception ex)
{
return new ApiResult { code = -1, msg = "淇濆瓨閿欒/"+ex.ToString() };
- }
- finally
- {
- dicLock.TryRemove(omodel.HBillNo, out string key);
}
}
public static ApiResult SetInBill(ClsSc_StationInBillMain omodel)
--
Gitblit v1.9.1