WebAPI/Controllers/NewApiController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/DbUntil/DataFormatUntil.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/ApiConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/ApiResult.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/DocumentsView.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Service/YqnQbService.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/WebAPI.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/WebAPI.csproj.user | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
WebAPI/Controllers/NewApiController.cs
New file @@ -0,0 +1,83 @@ using 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); } } } WebAPI/DbUntil/DataFormatUntil.cs
New file @@ -0,0 +1,68 @@ using 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转list /// </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转model /// </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() { //初始化 如果为null 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; } } } WebAPI/Models/ApiConfig.cs
New file @@ -0,0 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebAPI.Models { public class ApiConfig { public static string HBillType = "1238";//单据类型 } } WebAPI/Models/ApiResult.cs
New file @@ -0,0 +1,20 @@ using 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; } } } WebAPI/Models/DocumentsView.cs
New file @@ -0,0 +1,13 @@ using 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; } } } WebAPI/Service/YqnQbService.cs
New file @@ -0,0 +1,139 @@ using 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 生产资源代码,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 生产班组代码,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 工作中心代码,HName 工作中心 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source"); return dataSet; } #endregion } } 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> 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>