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 System.Data.SqlClient; using System.Data; namespace Procurement.Controllers { [Produces("application/json")] [Route("api/wms/[controller]")] public class BarcodeTraceController : AbpController { private readonly ISqlRepository _repository; public BarcodeTraceController(ISqlRepository sqlRepository) { _repository = sqlRepository; } [HttpGet] public async Task Get(string domain, string barcode) { 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 = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar}, }; items = await _repository.GetListByProcAsync("pr_WMS_GetBarcodeTraceList", 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("hist")] [HttpGet] public async Task Hist(string domain, string type, string barcode = "", int recid = 0) { 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 = "@Type", Value = type,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@RecID", Value = recid,SqlDbType=SqlDbType.BigInt}, }; items = await _repository.GetListByProcAsync("pr_WMS_GetBarcodeTransHistList", 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("single")] [HttpGet] public async Task SingleBarCode(string domain, string barcode, bool isapp = false) { 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 = "@BarCode", Value = barcode,SqlDbType=SqlDbType.VarChar}, new SqlParameter { ParameterName = "@IsApp", Value = isapp,SqlDbType=SqlDbType.Int}, }; items = await _repository.GetListByProcAsync("pr_SFM_SingleLabelBarcodeTrackHist", parameters); } catch (Exception ex) { subMsg = ex.Message; code = ResultCode.Fail; subCode = ResultCode.Fail; } ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg); return Ok(result); } } }