| | |
| | | } |
| | | |
| | | #region |
| | | |
| | | static object lockObj = new object(); |
| | | public string CreateCodeByRule(string ruleCode) |
| | | { |
| | | lock (lockObj) |
| | | { |
| | | string code = string.Empty; |
| | | DateTime dataTime = DateTime.Now; |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw new Exception(ex.Message); |
| | | } |
| | | return code; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region åä½è½¬æ¢ |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | private readonly IRepository<Dt_OutboundOrder> _outboundOrderRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRepository<Dt_AllocateOrder> _allocateRepository; |
| | | private readonly IRepository<Dt_MaterialCodeInfo> _materialCodeInfoRepository; |
| | | |
| | | public FeedbackMesService(IRepository<Dt_MesReturnRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, HttpClientHelper httpClientHelper, IRepository<Dt_OutboundOrder> outboundOrderRepository, IBasicService basicService, IRepository<Dt_AllocateOrder> allocateRepository) : base(BaseDal) |
| | | public FeedbackMesService(IRepository<Dt_MesReturnRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, HttpClientHelper httpClientHelper, IRepository<Dt_OutboundOrder> outboundOrderRepository, IBasicService basicService, IRepository<Dt_AllocateOrder> allocateRepository, IRepository<Dt_MaterialCodeInfo> materialCodeInfoRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _httpClientHelper = httpClientHelper; |
| | | _outboundOrderRepository = outboundOrderRepository; |
| | | _basicService = basicService; |
| | | _allocateRepository = allocateRepository; |
| | | _materialCodeInfoRepository = materialCodeInfoRepository; |
| | | } |
| | | |
| | | public WebResponseContent OutboundFeedback(string orderNo) |
| | |
| | | InterfaceType = 1, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OrderType = outboundOrder.OrderType, |
| | | RequestCode = reqCode, |
| | | RequestData = requestData, |
| | | FailureReason = message, |
| | |
| | | InterfaceType = 1, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OrderType = outboundOrder.OrderType, |
| | | RequestCode = returnDTO.ReqCode, |
| | | RequestData = returnDTO.Serialize(), |
| | | FailureReason = message, |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent BarcodeFeedback(string newBarcode) |
| | | { |
| | | try |
| | | { |
| | | Dt_MaterialCodeInfo materialCodeInfo = _materialCodeInfoRepository.QueryFirst(x => x.NewBarcode == newBarcode, new Dictionary<string, OrderByType> { { nameof(Dt_MaterialCodeInfo.Id), OrderByType.Desc } }); |
| | | if (materialCodeInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç©ææ¡ç ä¿¡æ¯{newBarcode}"); |
| | | } |
| | | |
| | | string apiUrl = ""; |
| | | |
| | | BarcodeReturnDTO returnDTO = new BarcodeReturnDTO() |
| | | { |
| | | BatchNo = materialCodeInfo.BatchNo, |
| | | FactoryArea = materialCodeInfo.FactoryArea, |
| | | OperationType = 1, |
| | | MaterialCode = materialCodeInfo.MaterialCode, |
| | | NewmaterialCode = materialCodeInfo.NewBarcode, |
| | | OldmaterialCode = materialCodeInfo.OldBarcode, |
| | | Operator = materialCodeInfo.Creater, |
| | | Qty = materialCodeInfo.AfterQuantity, |
| | | SupplyCode = materialCodeInfo.SuplierCode, |
| | | Unit = materialCodeInfo.Unit, |
| | | WarehouseCode = materialCodeInfo.WarehouseCode |
| | | }; |
| | | |
| | | string reqCode = Guid.NewGuid().ToString(); |
| | | string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | string requestData = returnDTO.Serialize(); |
| | | |
| | | HttpResponseResult<MesResponseDTO> httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, requestData); |
| | | httpResponseResult.ApiUrl = apiUrl; |
| | | |
| | | bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data != null && httpResponseResult.Data.Code == "200"; |
| | | string message = "æå"; |
| | | if (!isSuccess) |
| | | { |
| | | if (!httpResponseResult.IsSuccess) |
| | | { |
| | | message = $"MESæ¥å£è¿åé误ï¼HTTP代ç ï¼{httpResponseResult.StatusCode}ï¼ä¿¡æ¯ï¼{httpResponseResult.ErrorMessage}"; |
| | | } |
| | | else if (httpResponseResult.Data.Code != "200") |
| | | { |
| | | message = $"è°ç¨MESæ¥å£å¤±è´¥ï¼ä»£ç ï¼{httpResponseResult.Data.Code}ï¼ä¿¡æ¯ï¼{httpResponseResult.Data.Message}"; |
| | | } |
| | | } |
| | | |
| | | Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord() |
| | | { |
| | | ApiUrl = httpResponseResult.ApiUrl, |
| | | InterfaceType = 1, |
| | | OrderId = materialCodeInfo.OrderId ?? 0, |
| | | OrderNo = materialCodeInfo.OrderNo ?? "", |
| | | RequestCode = reqCode, |
| | | RequestData = requestData, |
| | | FailureReason = message, |
| | | LastReturnTime = DateTime.Now, |
| | | HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(), |
| | | ResponseData = httpResponseResult.Content, |
| | | ReturnType = 0, |
| | | ReturnCount = 1, |
| | | ReturnStatus = httpResponseResult.IsSuccess ? 1 : 2, |
| | | SuccessTime = httpResponseResult.IsSuccess ? DateTime.Now : null |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand(); |
| | | materialCodeInfo.ReturnStatus = httpResponseResult.IsSuccess ? 1 : 2; |
| | | _materialCodeInfoRepository.UpdateData(materialCodeInfo); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | responseContent.Status = isSuccess; |
| | | responseContent.Message = message; |
| | | return responseContent; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (entityInfo.EntityValue is BaseEntity baseEntity) |
| | | if (entityInfo.EntityValue is BaseEntity entity && entityInfo.EntityValue is IBaseHistoryEntity historyEntity) |
| | | { |
| | | if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(BaseEntity.CreateDate)) |
| | | { |
| | | historyEntity.InsertTime = DateTime.Now; |
| | | } |
| | | } |
| | | else if (entityInfo.EntityValue is BaseEntity baseEntity) |
| | | { |
| | | // æ°å¢æä½ |
| | | if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(BaseEntity.CreateDate)) |
| | |
| | | baseEntity.Creater = App.User.UserName; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (entityInfo.EntityValue is IBaseHistoryEntity baseHistoryEntity) |
| | | { |
| | | if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(IBaseHistoryEntity.InsertTime)) |
| | | { |
| | | baseHistoryEntity.InsertTime = DateTime.Now; |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System"); |
| | | } |
| | | else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate)) |
| | | { |
| | | propertyInfo.SetValue(obj, DateTime.Now); |
| | | } |
| | | else |
| | | { |
| | | propertyInfo.SetValue(obj, property.GetValue(entity)); |
| | |
| | | return DeleteData(entity); |
| | | |
| | | } |
| | | |
| | | //public bool DeleteAndMoveIntoHty(TEntity entity, OperateTypeEnum operateType) |
| | | //{ |
| | | // // æ ¸å¿é»è¾ï¼ç¨äºå¡ä¿è¯ååæ§ï¼å¼å¸¸æè·é¿å
æµç¨ä¸æï¼æ¥å¿è¾
å©ææ¥ |
| | | // bool isSuccess = false; |
| | | // string entityTypeName = entity?.GetType().Name ?? "æªç¥å®ä½"; |
| | | |
| | | // try |
| | | // { |
| | | // // åç½®æ ¡éªï¼å®ä½ä¸è½ä¸ºç©º |
| | | // if (entity == null) |
| | | // { |
| | | // return false; |
| | | // } |
| | | |
| | | // Type entityType = entity.GetType(); |
| | | // Assembly assembly = entityType.Assembly; |
| | | // string htyTypeName = $"{entityType.FullName}_Hty"; |
| | | // Type? htyType = assembly.GetType(htyTypeName); |
| | | |
| | | // // 1. æ£æ¥åå²è¡¨ç±»åæ¯å¦åå¨ |
| | | // if (htyType == null) |
| | | // { |
| | | |
| | | // return false; |
| | | // } |
| | | |
| | | // // 2. å建åå²è¡¨å®ä¾ï¼å¤çæ åæé 彿°ä¸åå¨çæ
åµï¼ |
| | | // object? htyObj; |
| | | // try |
| | | // { |
| | | // htyObj = Activator.CreateInstance(htyType); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // // _logger.LogError(ex, "DeleteAndMoveIntoHtyï¼å建åå²è¡¨å®ä¾ {HtyTypeName} 失败", htyTypeName); |
| | | // return false; |
| | | // } |
| | | // if (htyObj == null) |
| | | // { |
| | | // // _logger.LogWarning("DeleteAndMoveIntoHtyï¼åå²è¡¨å®ä¾ {HtyTypeName} åå»ºç»æä¸ºnull", htyTypeName); |
| | | // return false; |
| | | // } |
| | | |
| | | // // 3. è·åæ ¸å¿å±æ§ï¼æå®BindingFlagsç¡®ä¿è·åå
Œ
±å®ä¾å±æ§ï¼ |
| | | // BindingFlags propFlags = BindingFlags.Public | BindingFlags.Instance; |
| | | // PropertyInfo? keyPro = typeof(TEntity).GetKeyProperty(); // èªå®ä¹æ¹æ³éç¡®ä¿è¿åéç©ºï¼æ¤å¤å¢å å¤ç©º |
| | | // PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType), propFlags); |
| | | // PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId), propFlags); |
| | | |
| | | // // æ ¡éªæ ¸å¿å±æ§æ¯å¦åå¨ |
| | | // if (keyPro == null) |
| | | // { |
| | | // //_logger.LogError("DeleteAndMoveIntoHtyï¼å®ä½ {EntityType} æªæ¾å°ä¸»é®å±æ§", entityType.FullName); |
| | | // return false; |
| | | // } |
| | | // if (operateTypePro == null) |
| | | // { |
| | | // //_logger.LogError("DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} æªæ¾å°OperateType屿§", htyTypeName); |
| | | // return false; |
| | | // } |
| | | // if (sourceIdPro == null) |
| | | // { |
| | | // // _logger.LogError("DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} æªæ¾å°SourceId屿§", htyTypeName); |
| | | // return false; |
| | | // } |
| | | |
| | | // // 4. èµå¼æ ¸å¿å±æ§ï¼æ ¡éªç±»åå¹é
ï¼é¿å
SetValueæå¼å¸¸ï¼ |
| | | // try |
| | | // { |
| | | // // å¤çOperateTypeç±»åå¹é
ï¼è¥åå²è¡¨å±æ§æ¯æä¸¾ç±»åï¼ç´æ¥ä¼ æä¸¾èéå符串 |
| | | // if (operateTypePro.PropertyType == typeof(OperateTypeEnum)) |
| | | // { |
| | | // operateTypePro.SetValue(htyObj, operateType); |
| | | // } |
| | | // else if (operateTypePro.PropertyType == typeof(string)) |
| | | // { |
| | | // operateTypePro.SetValue(htyObj, operateType.ToString()); |
| | | // } |
| | | // else |
| | | // { |
| | | // //_logger.LogError("DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} çOperateType屿§ç±»å {PropType} ä¸å¹é
ï¼ä»
æ¯ææä¸¾/å符串ï¼", htyTypeName, operateTypePro.PropertyType.FullName); |
| | | // return false; |
| | | // } |
| | | |
| | | // // èµå¼SourceIdï¼æ ¡éªç±»åå¹é
ï¼ |
| | | // object sourceIdValue = keyPro.GetValue(entity)!; |
| | | // if (sourceIdPro.PropertyType != sourceIdValue.GetType()) |
| | | // { |
| | | // sourceIdValue = Convert.ChangeType(sourceIdValue, sourceIdPro.PropertyType); // ç±»åè½¬æ¢ |
| | | // } |
| | | // sourceIdPro.SetValue(htyObj, sourceIdValue); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // // _logger.LogError(ex, "DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} æ ¸å¿å±æ§èµå¼å¤±è´¥", htyTypeName); |
| | | // return false; |
| | | // } |
| | | |
| | | // // 5. èµå¼å
¶ä»å±æ§ï¼æé¤æ ¸å¿å±æ§ï¼ |
| | | // List<PropertyInfo> htyProperties = htyType.GetProperties(propFlags) |
| | | // .Where(x => x.Name != operateTypePro.Name |
| | | // && x.Name != sourceIdPro.Name |
| | | // && x.Name != keyPro.Name) |
| | | // .ToList(); |
| | | |
| | | // foreach (PropertyInfo htyProp in htyProperties) |
| | | // { |
| | | // PropertyInfo? entityProp = entityType.GetProperty(htyProp.Name, propFlags); |
| | | // if (entityProp == null) continue; // å®ä½æ è¯¥å±æ§åè·³è¿ |
| | | |
| | | // try |
| | | // { |
| | | // object propValue; |
| | | // // å¤çä¿®æ¹äººï¼é¿å
App.User空å¼ç¨ |
| | | // if (htyProp.Name == nameof(BaseEntity.Modifier)) |
| | | // { |
| | | // propValue = App.User?.UserId > 0 ? App.User?.UserName : "System"; |
| | | // } |
| | | // // å¤çä¿®æ¹æ¶é´ |
| | | // else if (htyProp.Name == nameof(BaseEntity.ModifyDate)) |
| | | // { |
| | | // propValue = DateTime.Now; |
| | | // } |
| | | // // å
¶ä»å±æ§ä»åå®ä½åå¼ |
| | | // else |
| | | // { |
| | | // propValue = entityProp.GetValue(entity) ?? DBNull.Value; // å¤çnullå¼ |
| | | // } |
| | | |
| | | // // ç±»å转æ¢åèµå¼ï¼é¿å
ç±»åä¸å¹é
ï¼ |
| | | // if (propValue != DBNull.Value && propValue != null) |
| | | // { |
| | | // propValue = Convert.ChangeType(propValue, htyProp.PropertyType); |
| | | // } |
| | | // htyProp.SetValue(htyObj, propValue); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // // _logger.LogWarning(ex, "DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} 屿§ {PropName} èµå¼å¤±è´¥ï¼è·³è¿è¯¥å±æ§", htyTypeName, htyProp.Name); |
| | | // } |
| | | // } |
| | | // try |
| | | // { |
| | | // // æ§è¡æå
¥åå²è¡¨ |
| | | // int insertRows = _db.InsertableByObject(htyObj).AS(entityType.Name + "_Hty").ExecuteCommand(); |
| | | |
| | | // if (insertRows <= 0) |
| | | // { |
| | | // // _logger.LogError("DeleteAndMoveIntoHtyï¼åå²è¡¨ {HtyTypeName} æå
¥å¤±è´¥ï¼å½±åè¡æ°0ï¼", htyTypeName); |
| | | // _db.InsertableByObject(htyObj).AS(entityType.Name + "_Hty").ExecuteCommand(); |
| | | // return false; |
| | | // } |
| | | // // æå
¥æååæ§è¡å é¤ |
| | | // bool deleteSuccess = DeleteData(entity); |
| | | // if (!deleteSuccess) |
| | | // { |
| | | // //_logger.LogError("DeleteAndMoveIntoHtyï¼å®ä½ {EntityType} å é¤å¤±è´¥", entityType.FullName); |
| | | // DeleteData(entity); |
| | | // return false; |
| | | // } |
| | | // // æäº¤äºå¡ |
| | | |
| | | // isSuccess = true; |
| | | // //_logger.LogInformation("DeleteAndMoveIntoHtyï¼å®ä½ {EntityType} å·²æåç§»å
¥åå²è¡¨å¹¶å é¤åæ°æ®", entityType.FullName); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | |
| | | // // _logger.LogError(ex, "DeleteAndMoveIntoHtyï¼äºå¡æ§è¡å¤±è´¥ï¼æå
¥åå²è¡¨/å é¤åæ°æ®ï¼", entityType.FullName); |
| | | // return false; |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // // _logger.LogError(ex, "DeleteAndMoveIntoHtyï¼å¤çå®ä½ {EntityTypeName} æ¶åçæªæè·å¼å¸¸", entityTypeName); |
| | | // return false; |
| | | // } |
| | | |
| | | // return isSuccess; |
| | | //} |
| | | |
| | | |
| | | |
| | | public bool DeleteAndMoveIntoHty(List<TEntity> entities, OperateTypeEnum operateType) |
| | |
| | | } |
| | | return DeleteData(entities); |
| | | } |
| | | //List<TResult> QueryMuch<T, T2, T3, TResult>( |
| | | // Expression<Func<T, T2, T3, object[]>> joinExpression, |
| | | // Expression<Func<T, T2, T3, TResult>> selectExpression, |
| | | // Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new(){throw new NotImplementedException();} |
| | | //Task<PageModel<TEntity>> QueryPage(PaginationModel pagination){throw new NotImplementedException();} |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.ReturnMES |
| | | { |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class BarcodeReturnDTO : BaseReturnDTO |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string OldmaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string NewmaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string Unit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string FactoryArea { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public decimal Qty { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string SupplyCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string BatchNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string MaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string WarehouseCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public int OperationType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string Operator { get; set; } |
| | | } |
| | | } |
| | |
| | | public interface IFeedbackMesService : IDependency |
| | | { |
| | | WebResponseContent OutboundFeedback(string orderNo); |
| | | |
| | | WebResponseContent BarcodeFeedback(string newBarcode); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using SqlSugar; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_AllocateMaterialInfo))] |
| | | public class Dt_AllocateMaterialInfo : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 订åä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "订å主é®")] |
| | | public int OrderId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 订åå· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "订åå·")] |
| | | public string OrderNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©æç¼å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç©æç¼å·")] |
| | | public string MaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©æåç§° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "ç©æåç§°")] |
| | | public string MaterialName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ååº |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "ååº")] |
| | | public string FactoryArea { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ¬¡ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "æ¹æ¬¡")] |
| | | public string BatchNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ°é |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, DecimalDigits = 3, ColumnDescription = "æ°é")] |
| | | public decimal Quantity { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä½ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 20, ColumnDescription = "åä½")] |
| | | public string Unit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä¾åºå |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "ä¾åºå")] |
| | | public string SupplyCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»åº |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "ä»åº")] |
| | | public string WarehouseCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©æç |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç©æç ")] |
| | | public string Barcode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "夿³¨")] |
| | | public string Remark { get; set; } |
| | | } |
| | | } |
| | |
| | | public string? SuplierCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true)] |
| | | public int? OrderId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50)] |
| | | public string? OrderNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// éè´åå· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "éè´åå·")] |
| | |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "ååº")] |
| | | public string? FactoryArea { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "ååº")] |
| | | public string? WarehouseCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ |
| | |
| | | public string Unit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int ReturnStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "夿³¨")] |
| | |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®ç±»å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int OrderType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®ä¸»è¡¨ID |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | |
| | | using AutoMapper; |
| | | using System.Reflection.Emit; |
| | | using AutoMapper; |
| | | using Dm.filter; |
| | | using MailKit.Search; |
| | | using Mapster; |
| | |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | | using Org.BouncyCastle.Crypto; |
| | | using SqlSugar; |
| | | using System.Reflection.Emit; |
| | | using WIDESEA_BasicService; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | |
| | | using WIDESEA_IRecordService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | using static HslCommunication.Profinet.Knx.KnxCode; |
| | | |
| | | namespace WIDESEA_OutboundService |
| | | { |
| | |
| | | private readonly IRepository<Dt_Task> _taskRepository; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IESSApiService _eSSApiService; |
| | | private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository; |
| | | |
| | | private Dictionary<string, string> stations = new Dictionary<string, string> |
| | | { |
| | |
| | | {"3-1","3-5" }, |
| | | }; |
| | | |
| | | public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService) |
| | | public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _taskRepository = taskRepository; |
| | | _locationInfoService = locationInfoService; |
| | | _eSSApiService = eSSApiService; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _allocateMaterialInfoRepository = allocateMaterialInfoRepository; |
| | | } |
| | | |
| | | #region åºåºåé
|
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region æ´ç®±åºåº |
| | | public WebResponseContent CompleteOutboundWithPallet(OutboundCompletePalletRequestDTO request) |
| | | { |
| | | WebResponseContent content = WebResponseContent.Instance; |
| | |
| | | // æ´ç®±åºåºæ éæå
|
| | | PerformFullOutboundOperation(stockInfo, request, lockInfo.TaskNum.GetValueOrDefault()); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | { |
| | | |
| | | Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo); |
| | | if (allocateOrder != null) |
| | | { |
| | | List<Dt_AllocateMaterialInfo> allocateMaterialInfos = new List<Dt_AllocateMaterialInfo>(); |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | | Barcode = item.Barcode, |
| | | BatchNo = item.BatchNo, |
| | | FactoryArea = item.FactoryArea, |
| | | MaterialCode = item.MaterielCode, |
| | | MaterialName = item.MaterielName, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | Quantity = item.StockQuantity, |
| | | SupplyCode = item.SupplyCode, |
| | | Unit = item.Unit, |
| | | WarehouseCode = allocateOrder.ToWarehouse |
| | | }; |
| | | allocateMaterialInfos.Add(allocateMaterialInfo); |
| | | } |
| | | _allocateMaterialInfoRepository.AddData(allocateMaterialInfos); |
| | | } |
| | | } |
| | | |
| | | decimal allocatedQuantity = actualOutboundQuantity; |
| | | List<Dt_OutboundOrderDetail> updateDetails = new(); |
| | |
| | | _stockDetailRepository.DeleteData(stockInfo.Details); |
| | | _stockChangeRepository.AddData(changeRecords); |
| | | } |
| | | #endregion |
| | | |
| | | #region æ£é |
| | | /// <summary> |
| | |
| | | // 8. 夿æ¯å¦éè¦æå
ï¼å½åºåºæ°éå°äºåºåæ°éæ¶éè¦æå
ï¼ |
| | | bool isUnpacked = actualOutboundQuantity < stockDetail.StockQuantity; |
| | | List<MaterialCodeReturnDTO> returnDTOs = new List<MaterialCodeReturnDTO>(); |
| | | |
| | | string newBarcode = string.Empty; |
| | | // 9. å¼å¯äºå¡ |
| | | _unitOfWorkManage.BeginTran(); |
| | | try |
| | | { |
| | | decimal beforeQuantity = stockDetail.StockQuantity; // åå§åºåé |
| | | |
| | | Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo(); |
| | | |
| | | // æ ¹æ®æ¯å¦æå
æ§è¡ä¸åçæä½ |
| | | if (isUnpacked) |
| | | { |
| | | returnDTOs = PerformUnpackOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault()); |
| | | (string NewBarcode, List<MaterialCodeReturnDTO> MaterialCodeReturnDTOs) result = PerformUnpackOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault(), outboundOrder.Id, outboundOrder.OrderNo); |
| | | |
| | | returnDTOs = result.MaterialCodeReturnDTOs; |
| | | newBarcode = result.NewBarcode; |
| | | |
| | | MaterialCodeReturnDTO returnDTO = returnDTOs.First(x => x.Barcode == newBarcode); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | { |
| | | allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | | Barcode = returnDTO.Barcode, |
| | | BatchNo = returnDTO.BatchNo, |
| | | FactoryArea = returnDTO.FactoryArea, |
| | | MaterialCode = returnDTO.MaterialCode, |
| | | MaterialName = returnDTO.MaterialName, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | Quantity = returnDTO.Quantity, |
| | | SupplyCode = returnDTO.SuplierCode, |
| | | Unit = stockDetail.Unit |
| | | }; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | PerformFullOutboundOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault()); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | { |
| | | allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | | Barcode = stockDetail.Barcode, |
| | | BatchNo = stockDetail.BatchNo, |
| | | FactoryArea = stockDetail.FactoryArea, |
| | | MaterialCode = stockDetail.MaterielCode, |
| | | MaterialName = stockDetail.MaterielName, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | Quantity = stockDetail.StockQuantity, |
| | | SupplyCode = stockDetail.SupplyCode, |
| | | Unit = stockDetail.Unit |
| | | }; |
| | | } |
| | | |
| | | } |
| | | |
| | | // 夿æ¯å¦æ¯è°æ¨å |
| | | if (outboundOrder.OrderType != 0) |
| | | { |
| | | Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo); |
| | | if (allocateOrder != null) |
| | | { |
| | | allocateMaterialInfo.WarehouseCode = allocateOrder.ToWarehouse; |
| | | |
| | | _allocateMaterialInfoRepository.AddData(allocateMaterialInfo); |
| | | } |
| | | } |
| | | |
| | | decimal allocatedQuantity = actualOutboundQuantity; |
| | |
| | | response.ScannedDetail = scannedDetail; |
| | | response.UpdatedDetails = updateDetails; |
| | | |
| | | if (!string.IsNullOrEmpty(newBarcode)) |
| | | { |
| | | // ç©ææ°æ¡ç åä¼ |
| | | _feedbackMesService.BarcodeFeedback(newBarcode); |
| | | } |
| | | |
| | | // æ£æ¥åºåºåæ¯å¦å®æ |
| | | if (CheckOutboundOrderCompleted(request.OrderNo)) |
| | | { |
| | |
| | | /// <param name="beforeQuantity"></param> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | private List<MaterialCodeReturnDTO> PerformUnpackOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo, |
| | | decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum) |
| | | private (string NewBarcode, List<MaterialCodeReturnDTO> MaterialCodeReturnDTOs) PerformUnpackOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo, |
| | | decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum, int orderId, string orderNo) |
| | | { |
| | | string newBarcode = GenerateNewBarcode(); |
| | | |
| | | string remark = $"æå
è®°å½ï¼åæ¡ç ï¼{request.Barcode}ï¼åæ°éï¼{stockDetail.StockQuantity}ï¼åºåºæ¡ç ï¼{newBarcode}ï¼ åºåºæ°éï¼{actualOutboundQuantity}ï¼ååºæ¡ç ï¼{request.Barcode}ï¼ååºæ°éï¼{stockDetail.StockQuantity - actualOutboundQuantity},æä½è
ï¼{request.Operator}"; |
| | | |
| | | List<Dt_MaterialCodeInfo> materialCodeInfos = CreateMaterialCodeInfos(stockDetail, newBarcode, actualOutboundQuantity, remark); |
| | | List<Dt_MaterialCodeInfo> materialCodeInfos = CreateMaterialCodeInfos(stockDetail, newBarcode, actualOutboundQuantity, remark, taskNum, orderId, orderNo); |
| | | |
| | | List<MaterialCodeReturnDTO> returnDTOs = _mapper.Map<List<MaterialCodeReturnDTO>>(materialCodeInfos); |
| | | |
| | |
| | | SupplyCode = stockDetail.SupplyCode, |
| | | FactoryArea = stockDetail.FactoryArea, |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"æå
ååå§è®°å½ï¼åæ¡ç ï¼{request.Barcode}ï¼åæ°éï¼{stockDetail.StockQuantity}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | Remark = $"æå
ååå§è®°å½ï¼åºåºåå·ï¼{orderNo}ï¼åºåºå主é®ï¼{orderId}ï¼åæ¡ç ï¼{request.Barcode}ï¼åæ°éï¼{stockDetail.StockQuantity}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockDetailHistoryRepository.AddData(originalHistoryRecord); |
| | | |
| | |
| | | // æ´æ°ååºåæç» |
| | | stockDetail.StockQuantity = remainingQuantity; |
| | | //stockDetail.Barcode = newBarcode; |
| | | stockDetail.Remark = $"æå
åæ´æ°ï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ°éï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}"; |
| | | stockDetail.Remark = $"æå
åæ´æ°ï¼åºåºåå·ï¼{orderNo}ï¼åºåºå主é®ï¼{orderId}ï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ°éï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}"; |
| | | _stockDetailRepository.UpdateData(stockDetail); |
| | | } |
| | | |
| | |
| | | AfterQuantity = beforeQuantity - actualOutboundQuantity, |
| | | SupplyCode = stockDetail.SupplyCode, |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"æå
åºåºï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ¡ç ï¼{newBarcode}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼å©ä½ï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | Remark = $"æå
åºåºï¼åºåºåå·ï¼{orderNo}ï¼åºåºå主é®ï¼{orderId}ï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ¡ç ï¼{newBarcode}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼å©ä½ï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockChangeRepository.AddData(unpackChangeRecord); |
| | | |
| | | return returnDTOs; |
| | | return (newBarcode, returnDTOs); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="afterQuantity"></param> |
| | | /// <param name="remark"></param> |
| | | /// <returns></returns> |
| | | private List<Dt_MaterialCodeInfo> CreateMaterialCodeInfos(Dt_StockInfoDetail stockDetail, string newBarcode, decimal splitQuantity, string remark) |
| | | private List<Dt_MaterialCodeInfo> CreateMaterialCodeInfos(Dt_StockInfoDetail stockDetail, string newBarcode, decimal splitQuantity, string remark, int taskNum, int orderId, string orderNo) |
| | | { |
| | | List<Dt_MaterialCodeInfo> materialCodeInfos = new List<Dt_MaterialCodeInfo>(); |
| | | |
| | |
| | | SuplierCode = stockDetail.SupplyCode, |
| | | Unit = stockDetail.Unit, |
| | | Date = DateTime.Now.ToString("yyyy-MM-dd"), |
| | | Remark = remark |
| | | Remark = remark, |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | OrderNo = orderNo, |
| | | OrderId = orderId, |
| | | ReturnStatus = 0 |
| | | }; |
| | | materialCodeInfos.Add(outMaterialCodeInfo); |
| | | |
| | |
| | | SuplierCode = stockDetail.SupplyCode, |
| | | Unit = stockDetail.Unit, |
| | | Date = DateTime.Now.ToString("yyyy-MM-dd"), |
| | | Remark = remark |
| | | Remark = remark, |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | OrderNo = orderNo, |
| | | OrderId = orderId, |
| | | ReturnStatus = 0 |
| | | }; |
| | | |
| | | materialCodeInfos.Add(returnMaterialCodeInfo); |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region |
| | | #region ååº |
| | | public async Task<WebResponseContent> ReturnToWarehouse(string palletCode, string OrderNo, string station) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |