using Procurement.Enums; using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc; using Procurement.EntityFrameworkCore.SqlRepositories; using Procurement.ViewModel; using Procurement.Helpers; using Procurement.Services; using System.Data.SqlClient; using System.Data; namespace Procurement.Controllers { [Produces("application/json")] [Route("api/wms/[controller]")] public class CommonController : AbpController { private readonly ISqlRepository _repository; public CommonController(ISqlRepository sqlRepository) { _repository = sqlRepository; } /// /// 页面初始数据 /// /// /// [Route("init")] [HttpGet] public async Task Get(string type) { ResultCode code = ResultCode.Success, subCode = ResultCode.Success; string subMsg = ""; dynamic items = null; try { SqlParameter[] parameters = { new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar} }; items = await _repository.GetListByProcAsync("pr_WMS_GetCommonInit", parameters); } catch (Exception ex) { subMsg = ex.Message; code = ResultCode.Fail; subCode = ResultCode.Fail; } ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg); return Ok(result); } /// /// 扫描条码 /// /// /// /// /// /// [Route("scanbarcode")] [HttpGet] public async Task Get(string domain, string purord, string barcode, string type, string userno = "") { ResultCode code = ResultCode.Success, subCode = ResultCode.Success; string subMsg = ""; dynamic items = null; try { SqlParameter[] parameters = { new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@PurOrd", Value = purord,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@UserNo", Value = userno,SqlDbType=SqlDbType.VarChar} }; items = await _repository.GetListByProcAsync("pr_WMS_GetBarCodes", parameters); } catch (Exception ex) { subMsg = ex.Message; code = ResultCode.Fail; subCode = ResultCode.Fail; } ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg); return Ok(result); } /// /// 选择列表 /// /// /// [Route("commonlist")] [HttpGet] public async Task Get(string domain, string type, string keyword = "", string keyword2 = "") { ResultCode code = ResultCode.Success, subCode = ResultCode.Success; string subMsg = ""; dynamic items = null; try { Common common = new Common(_repository); items = await common.GetCommonItems(domain, type, keyword, keyword2); } catch (Exception ex) { subMsg = ex.Message; code = ResultCode.Fail; subCode = ResultCode.Fail; } ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg); return Ok(result); } } }