From 71cb5772e28908d6ad100b111dbecf8b353c0b25 Mon Sep 17 00:00:00 2001 From: ouyangqing <ouyangqing@DESKTOP-B85SG1D> Date: 星期五, 15 一月 2021 17:33:40 +0800 Subject: [PATCH] 进站接收 --- WebAPI/Service/YqnQbService.cs | 139 +++++++++++++++++++++++ WebAPI/Models/ApiResult.cs | 20 +++ WebAPI/DbUntil/DataFormatUntil.cs | 68 +++++++++++ WebAPI/Models/ApiConfig.cs | 12 ++ WebAPI/Models/DocumentsView.cs | 13 ++ WebAPI/WebAPI.csproj.user | 2 WebAPI/WebAPI.csproj | 6 + WebAPI/Controllers/NewApiController.cs | 83 +++++++++++++ 8 files changed, 343 insertions(+), 0 deletions(-) diff --git a/WebAPI/Controllers/NewApiController.cs b/WebAPI/Controllers/NewApiController.cs new file mode 100644 index 0000000..3bc5b04 --- /dev/null +++ b/WebAPI/Controllers/NewApiController.cs @@ -0,0 +1,83 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using WebAPI.Models; +using WebAPI.Service; +using WebAPI.WebS; + +namespace WebAPI.Controllers +{ + public class NewApiController : ApiController + { + /// <summary> + /// 鑾峰彇鍗曟嵁鍙� + /// </summary> + /// <returns></returns> + [Route("api/newBill/getNewInterBillNo")] + [HttpGet] + public ApiResult<DocumentsView> GetNewInterBillNo() + { + var model = YqnQbService.GetInterBillNo(); + return model; + } + /// <summary> + /// 娴佽浆鍗¤幏鍙栦俊鎭� + /// </summary> + /// <returns></returns> + [Route("api/newBill/getHbarCodeDetail")] + [HttpGet] + public ApiResult<DataSet> GetHbarCodeDetail(string sBillBarCode) + { + var model = YqnQbService.GetHbarCodeDetail(sBillBarCode); + return model; + } + /// <summary> + /// 娴佹按鍙疯幏寰椾俊鎭� + /// </summary> + /// <returns></returns> + [Route("api/newBill/getProcDetail")] + [HttpGet] + public ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo) + { + var model = YqnQbService.GetProcDetail(sBillNo, sProcNo); + return model; + } + /// <summary> + /// 鑾峰彇鐢熶骇璧勬簮鍒楄〃 + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("api/newBill/getSourceList")] + [HttpGet] + public ApiResult<DataSet> GetSourceList(string sWhere) + { + return YqnQbService.GetSourceList(sWhere); + } + /// <summary> + /// 鑾峰彇宸ヤ綔涓績 + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("api/newBill/getSourceList")] + [HttpGet] + public ApiResult<DataSet> GetWorkCenterList(string sWhere) + { + return YqnQbService.GetWorkCenterList(sWhere); + } + /// <summary> + /// 杩涚珯鎺ユ敹鍗� + /// </summary> + /// <param name="oMain"></param> + /// <returns></returns> + [Route("api/newBill/setStationInBill")] + [HttpPost] + public ApiResult SetStationInBill(ClsSc_StationInBillMain oMain) + { + return YqnQbService.SetStationInBill(oMain); + } + } +} diff --git a/WebAPI/DbUntil/DataFormatUntil.cs b/WebAPI/DbUntil/DataFormatUntil.cs new file mode 100644 index 0000000..5779273 --- /dev/null +++ b/WebAPI/DbUntil/DataFormatUntil.cs @@ -0,0 +1,68 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Reflection; +using System.Web; + +namespace WebAPI.DbUntil +{ + public class DataFormatUntil + { + /// <summary> + /// dataset杞琹ist + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="entity"></param> + /// <param name="ds"></param> + /// <returns></returns> + public static List<T> PutAllVal<T>(T entity, DataSet ds) where T : new() + { + + List<T> lists = new List<T>(); + if (ds.Tables[0].Rows.Count > 0) + { + foreach (DataRow row in ds.Tables[0].Rows) + { + lists.Add(PutVal(new T(), row)); + } + } + return lists; + } + /// <summary> + /// datarow杞琺odel + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="entity"></param> + /// <param name="row"></param> + /// <returns></returns> + public static T PutVal<T>(T entity, DataRow row) where T : new() + { + //鍒濆鍖� 濡傛灉涓簄ull + if (entity == null) + { + entity = new T(); + } + //寰楀埌绫诲瀷 + Type type = typeof(T); + //鍙栧緱灞炴�ч泦鍚� + PropertyInfo[] pi = type.GetProperties(); + foreach (PropertyInfo item in pi) + { + //缁欏睘鎬ц祴鍊� + if (row[item.Name] != null && row[item.Name] != DBNull.Value) + { + if (item.PropertyType == typeof(System.Nullable<System.DateTime>)) + { + item.SetValue(entity, Convert.ToDateTime(row[item.Name].ToString()), null); + } + else + { + item.SetValue(entity, Convert.ChangeType(row[item.Name], item.PropertyType), null); + } + } + } + return entity; + } + } +} \ No newline at end of file diff --git a/WebAPI/Models/ApiConfig.cs b/WebAPI/Models/ApiConfig.cs new file mode 100644 index 0000000..688add3 --- /dev/null +++ b/WebAPI/Models/ApiConfig.cs @@ -0,0 +1,12 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace WebAPI.Models +{ + public class ApiConfig + { + public static string HBillType = "1238";//鍗曟嵁绫诲瀷 + } +} \ No newline at end of file diff --git a/WebAPI/Models/ApiResult.cs b/WebAPI/Models/ApiResult.cs new file mode 100644 index 0000000..42dcc71 --- /dev/null +++ b/WebAPI/Models/ApiResult.cs @@ -0,0 +1,20 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace WebAPI.Models +{ + public class ApiResult<T> + { + public int code { get; set; } + public string msg { get; set; } + public T data { get; set; } + public int count { get; set; } + } + public class ApiResult + { + public int code { get; set; } + public string msg { get; set; } + } +} \ No newline at end of file diff --git a/WebAPI/Models/DocumentsView.cs b/WebAPI/Models/DocumentsView.cs new file mode 100644 index 0000000..fbf6b37 --- /dev/null +++ b/WebAPI/Models/DocumentsView.cs @@ -0,0 +1,13 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace WebAPI.Models +{ + public class DocumentsView + { + public string HBillNo { get; set; } + public long HInterID { get; set; } + } +} \ No newline at end of file diff --git a/WebAPI/Service/YqnQbService.cs b/WebAPI/Service/YqnQbService.cs new file mode 100644 index 0000000..d046f5b --- /dev/null +++ b/WebAPI/Service/YqnQbService.cs @@ -0,0 +1,139 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Web; +using WebAPI.Models; +using WebAPI.WebS; + +namespace WebAPI.Service +{ + public class YqnQbService + { + /// <summary> + /// 鑾峰彇鍗曟嵁鍙� + /// </summary> + /// <returns></returns> + public static ApiResult<DocumentsView> GetInterBillNo() + { + var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo); + var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); + if (hInterId == 0 || string.IsNullOrEmpty(hBillNo)) + return new ApiResult<DocumentsView> { code = -1, msg = "鑾峰彇澶辫触" }; + DocumentsView documentsView = new DocumentsView() + { + HBillNo = hBillNo, + HInterID = hInterId + }; + return new ApiResult<DocumentsView> { code = 1, msg = "鑾峰彇鎴愬姛", data = documentsView }; + } + /// <summary> + /// 鎵爜鏂规硶 + /// </summary> + public static ApiResult<DataSet> GetHbarCodeDetail(string sBillBarCode) + { + if (string.IsNullOrEmpty(sBillBarCode)) + return new ApiResult<DataSet> { code = -1, msg = "鏉$爜涓嶈兘涓虹┖" }; + sBillBarCode = sBillBarCode.CompareTo("#") > 0 ? sBillBarCode.Split(Convert.ToChar("#"))[0] : sBillBarCode; + var dataSet = GetBarCodeDb(sBillBarCode); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄦ祦杞崱鍙�" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛",data=dataSet }; + } + /// <summary> + /// 娴佽浆鍗″洖杞︽柟娉� + /// </summary> + public static ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo) + { + if (string.IsNullOrEmpty(sBillNo)||string.IsNullOrEmpty(sProcNo)) + return new ApiResult<DataSet> { code = -1, msg = "鏉$爜鍜屾祦杞崱涓嶈兘涓虹┖" }; + var dataSet = GetProcDb(sBillNo, sProcNo); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "娴佹按鍙锋垨娴佽浆鍗″彿涓虹┖" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + /// <summary> + /// 鑾峰彇鐢熶骇璧勬簮鍒楄〃 + /// </summary> + public static ApiResult<DataSet> GetSourceList(string sWhere) + { + var dataSet = GetSourceDb(sWhere); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "鏈煡璇㈠埌鐢熶骇璧勬簮" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + /// <summary> + /// 鑾峰彇鐢熶骇鐝粍鍒楄〃 + /// </summary> + public static ApiResult<DataSet> GetGroupList(string sWhere) + { + var dataSet = GetGroupDb(sWhere); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "鏈煡璇㈠埌鐢熶骇鐝粍" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + /// <summary> + /// 鑾峰彇宸ヤ綔涓績鍒楄〃 + /// </summary> + public static ApiResult<DataSet> GetWorkCenterList(string sWhere) + { + var dataSet = GetGroupDb(sWhere); + if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) + return new ApiResult<DataSet> { code = -1, msg = "鏈煡璇㈠埌宸ヤ綔涓績" }; + return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; + } + /// <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) + { + return new ApiResult { code = -1, msg = sErrMsg }; + } + return new ApiResult { code = 1, msg = "鎿嶄綔鎴愬姛" }; + } + #region sql璇彞 + public static DataSet GetBarCodeDb(string billBarCode) + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 鍗曟嵁鍙�= '" + billBarCode + "'", "h_v_Sc_ProcessExchangeBillList"); + return dataSet; + } + public static DataSet GetSourceDb(string sWhere) + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 鐢熶骇璧勬簮浠g爜,HName 鐢熶骇璧勬簮 from Gy_Source where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source"); + return dataSet; + } + public static DataSet GetGroupDb(string sWhere) + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 鐢熶骇鐝粍浠g爜,HName 鐢熶骇鐝粍 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source"); + return dataSet; + } + + public static DataSet GetProcDb(string sBillNo, string sProcNo) + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 鍗曟嵁鍙�= '" + sBillNo + "' and 宸ュ簭鍙�='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList"); + return dataSet; + } + /// <summary> + /// 宸ヤ綔涓績 + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + public static DataSet GetWorkCenterDb(string sWhere) + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 宸ヤ綔涓績浠g爜,HName 宸ヤ綔涓績 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source"); + return dataSet; + } + #endregion + + } +} \ No newline at end of file diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj index 0d1c0ff..c7e7106 100644 --- a/WebAPI/WebAPI.csproj +++ b/WebAPI/WebAPI.csproj @@ -308,6 +308,11 @@ <Compile Include="App_Start\RouteConfig.cs" /> <Compile Include="App_Start\SwaggerConfig.cs" /> <Compile Include="App_Start\WebApiConfig.cs" /> + <Compile Include="Controllers\NewApiController.cs" /> + <Compile Include="DbUntil\DataFormatUntil.cs" /> + <Compile Include="Models\ApiConfig.cs" /> + <Compile Include="Models\ApiResult.cs" /> + <Compile Include="Models\DocumentsView.cs" /> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> @@ -318,6 +323,7 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> <DependentUpon>Settings.settings</DependentUpon> </Compile> + <Compile Include="Service\YqnQbService.cs" /> <Compile Include="Web References\WebS\Reference.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> diff --git a/WebAPI/WebAPI.csproj.user b/WebAPI/WebAPI.csproj.user index 8d4aa2e..1d7d7d6 100644 --- a/WebAPI/WebAPI.csproj.user +++ b/WebAPI/WebAPI.csproj.user @@ -17,6 +17,8 @@ <IISExpressUseClassicPipelineMode /> <UseGlobalApplicationHostFile /> <ProjectView>ProjectFiles</ProjectView> + <Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID> + <Controller_SelectedScaffolderCategoryPath>root/Common/Web API</Controller_SelectedScaffolderCategoryPath> </PropertyGroup> <ProjectExtensions> <VisualStudio> -- Gitblit v1.9.1