| | |
| | | using Org.BouncyCastle.Crypto; |
| | | using Newtonsoft.Json; |
| | | using Org.BouncyCastle.Crypto; |
| | | using SqlSugar; |
| | | using SqlSugar.Extensions; |
| | | //using SqlSugar.Extensions; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_Model; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.System.Reponse; |
| | | using WIDESEA_Model.Models.System.Request; |
| | | |
| | | namespace WIDESEA_StockRepository |
| | | { |
| | | public class StockInfoRepository : RepositoryBase<Dt_StockInfo>, IStockInfoRepository |
| | | { |
| | | public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) |
| | | private readonly ILabelMasterRepository _labelMasterRepository; |
| | | public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage,ILabelMasterRepository labelMasterRepository) : base(unitOfWorkManage) |
| | | { |
| | | _labelMasterRepository = labelMasterRepository; |
| | | } |
| | | |
| | | public List<StockViewDTO> GetAllStockViews() |
| | |
| | | //ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>(); |
| | | //ISugarQueryable<Dt_StockInfo> sugarQueryable1 = Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)); |
| | | //return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => b).Includes(x => x.Details).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®æ¹æ¬¡å·åç©æç¼ç è·ååºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | public List<Dt_StockInfo> GetStockInfos(string materielCode,string batchNo) |
| | | { |
| | | return Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode&&v.BatchNo==batchNo)).ToList(); |
| | | } |
| | | |
| | | public List<Dt_StockInfo> GetStockInfos(string materielCode, List<string> locationCodes) |
| | |
| | | return Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == StockStatusEmun.å·²å
¥åº.ObjToInt() && x.PalletCode.Substring(0, 1) == "B" && SqlFunc.Subqueryable<Dt_LocationInfo>().Where(v => v.LocationCode == x.LocationCode && v.RoadwayNo == roadwayNo && v.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (EnableStatusEnum.Normal.ObjToInt() == v.EnableStatus)).Any()).OrderBy(x => x.ModifyDate).First(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ç«åºWMSåºåä¿¡æ¯æ¥å£ï¼ä¾ä¸æ¸¸ç³»ç»è°ç¨ |
| | | /// </summary> |
| | | /// <param name="inventoryQueryRequest"></param> |
| | | /// <returns></returns> |
| | | public InventoryQueryResponse InventoryQuery(string inventoryQueryRequeststr) |
| | | { |
| | | InventoryQueryResponse inventoryQueryResponse = new InventoryQueryResponse(); |
| | | try |
| | | { |
| | | InventoryQueryRequest inventoryQueryRequest = JsonConvert.DeserializeObject<InventoryQueryRequest>(inventoryQueryRequeststr); |
| | | if (inventoryQueryRequest != null) |
| | | { |
| | | List<StockItem> DATA = new List<StockItem>(); |
| | | inventoryQueryResponse.DATA = DATA; |
| | | List<StockViewDTO> stockviews = GetAllStockViews(); |
| | | foreach (var view in stockviews) |
| | | { |
| | | foreach (var detail in view.Details) |
| | | { |
| | | Dt_LabelMaster labelMaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == detail.SerialNumber); |
| | | StockItem stockItem = new StockItem(); |
| | | stockItem.BATCH = detail.BatchNo; |
| | | stockItem.LABEL_NO = detail.SerialNumber; |
| | | stockItem.LGORT = "0030";//åºä½ |
| | | if (labelMaster != null) |
| | | { |
| | | if (labelMaster.WH_NUMBER == inventoryQueryRequest.DATA[0].WH_NUMBER && labelMaster.WERKS == inventoryQueryRequest.DATA[0].WH_NUMBER) |
| | | { |
| | | stockItem.LIFNR = labelMaster.LIFNR; |
| | | stockItem.LIKTX = labelMaster.LIKTX; |
| | | stockItem.LK_BIN_CODE = view.LocationCode; |
| | | stockItem.MAKTX = labelMaster.MAKTX; |
| | | stockItem.MATNR = labelMaster.MATNR; |
| | | stockItem.MEINS = labelMaster.UNIT; |
| | | stockItem.QTY = labelMaster.BOX_QTY; |
| | | stockItem.SOBKZ = labelMaster.SOBKZ; |
| | | stockItem.TPNUM = view.PalletCode; |
| | | stockItem.WERKS = labelMaster.WERKS;//å·¥å |
| | | stockItem.WH_NUMBER = labelMaster.WH_NUMBER;//ä»åºå· |
| | | DATA.Add(stockItem); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (DATA.Count > 0) |
| | | { |
| | | inventoryQueryResponse.MSGTY = "S"; |
| | | inventoryQueryResponse.MSGTX = ""; |
| | | } |
| | | else |
| | | { |
| | | inventoryQueryResponse.MSGTY = "I"; |
| | | inventoryQueryResponse.MSGTX = ""; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | inventoryQueryResponse.MSGTY = "E"; |
| | | inventoryQueryResponse.MSGTX = ex.Message; |
| | | |
| | | } |
| | | return inventoryQueryResponse; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç«åºWMSå»ç»/è§£å»ä¿¡æ¯æ¥å£ï¼ä¾ä¸æ¸¸ç³»ç»è°ç¨ |
| | | /// </summary> |
| | | /// <param name="freezeByCustomerResponse"></param> |
| | | /// <returns></returns> |
| | | public freezeByCustomerResponse freezeByCustomer(string freezeRequeststr) |
| | | { |
| | | |
| | | freezeByCustomerResponse freezeResponse = new freezeByCustomerResponse(); |
| | | try |
| | | { |
| | | freezeByCustomerRequest freezeRequest = JsonConvert.DeserializeObject<freezeByCustomerRequest>(freezeRequeststr); |
| | | if (freezeRequest.WERKS == AppSettings.Configuration["WERKS"] && freezeRequest.WH_NUMBER == AppSettings.Configuration["SYSNO"]) |
| | | { |
| | | //æ ¹æ®æ¹æ¬¡åç©æå·æ¥æ¾å¯¹åºçæçå·ï¼å»ç»åºåï¼åªæå
¥åºæåäºï¼æè½è¢«å»ç» |
| | | List<Dt_StockInfo> stockInfos = GetStockInfos(freezeRequest.MATNR, freezeRequest.BATCH); |
| | | if (freezeRequest.FREEZE_TYPE == "00")//00å»ç» |
| | | { |
| | | foreach (var item in stockInfos) |
| | | { |
| | | if (item.StockStatus == (int)StockStatusEmun.å·²å
¥åº) |
| | | { |
| | | item.StockStatus = (int)StockStatusEmun.åºåºå»ç»; |
| | | UpdateData(item); |
| | | } |
| | | } |
| | | freezeResponse.MSGTY = "S"; |
| | | freezeResponse.MSGTX = ""; |
| | | } |
| | | else if (freezeRequest.FREEZE_TYPE == "01") //01è§£å» |
| | | { |
| | | foreach (var item in stockInfos) |
| | | { |
| | | if (item.StockStatus == (int)StockStatusEmun.åºåºå»ç») |
| | | { |
| | | item.StockStatus = (int)StockStatusEmun.å·²å
¥åº; |
| | | UpdateData(item); |
| | | } |
| | | } |
| | | freezeResponse.MSGTY = "S"; |
| | | freezeResponse.MSGTX = ""; |
| | | |
| | | } |
| | | else |
| | | { |
| | | freezeResponse.MSGTY = "E"; |
| | | freezeResponse.MSGTX = "䏿¯æè¯¥ä¸å¡ç±»å"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | freezeResponse.MSGTY = "E"; |
| | | freezeResponse.MSGTX = "è¯·ä¼ å
¥æ£ç¡®çå·¥åå·åä»åºå·"; |
| | | |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | freezeResponse.MSGTY = "E"; |
| | | freezeResponse.MSGTX = ex.Message; |
| | | |
| | | } |
| | | return freezeResponse; |
| | | |
| | | } |
| | | } |
| | | } |