| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet("getOneWorkPiece")] |
| | | public async Task<WorkPieceInfoOutput> getOneWorkPiece([FromQuery] WorkPieceProcessPdaSearch input) |
| | | public async Task<WorkPieceInfoOutput> getOneWorkPiece([FromQuery] WorkPieceProcessPdaSearch input) |
| | | { |
| | | if (string.IsNullOrEmpty(input.WorkPieceID)) |
| | | { |
| | |
| | | WorkPieceCurrentPosition = s.c.a.WorkPieceCurrentPosition, |
| | | WorkPieceinitOnlineTime = s.c.a.WorkPieceinitOnlineTime, |
| | | WorkPieceLastOfflineTime = s.c.a.WorkPieceLastOfflineTime, |
| | | WorkingProcedureCompleted= s.c.a.WorkingProcedureCompleted, |
| | | OP80NewCode=s.c.a.OP80NewCode, |
| | | WorkingProcedureCompleted = s.c.a.WorkingProcedureCompleted, |
| | | OP80NewCode = s.c.a.OP80NewCode, |
| | | }) |
| | | .ProjectToType<WorkPieceInfoOutput>().FirstOrDefaultAsync(); |
| | | if (workPieceInfo == null) |
| | |
| | | // //.Where(x => (x.g.Code.Equals("equipment_state"))) |
| | | .Where(u => u.a.QualityState != (int)EnumQualityState.OK) |
| | | .Where(u => u.a.IsDeleted == false) |
| | | .Where(o => o.a.WorkPieceID.Contains(queryStr ?? "")|| o.a.QualityErrorInfo.Contains(queryStr ?? "")) |
| | | .Where(o => o.a.WorkPieceID.Contains(queryStr ?? "") || o.a.QualityErrorInfo.Contains(queryStr ?? "")) |
| | | //.Where(o => (o.a.QualityStateUpdateTime.HasValue ? o.a.QualityStateUpdateTime.Value : DateTime.MinValue) > DateTime.Now.AddDays(-7)) |
| | | .Where(o => !string.IsNullOrEmpty(o.a.WorkPieceID)) |
| | | .Select(s => new WorkPieceInfoOutput |
| | |
| | | WorkingProcedureCompleted = s.a.WorkingProcedureCompleted, |
| | | WorkPieceinitOnlineTime = s.a.WorkPieceinitOnlineTime, |
| | | QualityState = s.a.QualityState, |
| | | QualityErrorInfo= s.a.QualityErrorInfo, |
| | | QualityStateUpdateTime=(s.a.QualityStateUpdateTime.HasValue? s.a.QualityStateUpdateTime.Value:DateTime.MinValue), |
| | | QualityErrorInfo = s.a.QualityErrorInfo, |
| | | QualityStateUpdateTime = (s.a.QualityStateUpdateTime.HasValue ? s.a.QualityStateUpdateTime.Value : DateTime.MinValue), |
| | | EquipmentID = s.a.EquipmentID, |
| | | EquipmentName = s.b.EquipmentName, |
| | | //EquipmentCurrentState = s.d.EquipmentCurrentState, |
| | |
| | | throw Oops.Oh($"修改工件质量状态失败:工件{item}不存在!"); |
| | | } |
| | | |
| | | if(int.Parse(input.QualityState)==(int)EnumQualityState.OK) |
| | | if (int.Parse(input.QualityState) == (int)EnumQualityState.OK) |
| | | { |
| | | workPieceInfo.QualityErrorInfo = ""; |
| | | } |
| | |
| | | [HttpPost("updateWorkPieceInfo")] |
| | | public async Task<string> updateWorkPieceInfo([FromBody] UpdateQualityStateInput input) |
| | | { |
| | | if (input == null || input.WorkPieceIDList.Count == 0 || input.Password == null) |
| | | if (input == null || input.WorkPieceIDList.Count == 0 || input.Password == null) |
| | | { |
| | | throw Oops.Oh("修改工件信息失败:传参不能为空!"); |
| | | } |
| | |
| | | { |
| | | throw Oops.Oh($"修改工件信息失败:传入工件状态[{input.WorkPieceState}]不对!"); |
| | | } |
| | | if (input.WorkingProcedure.Length!=4|| !input.WorkingProcedure.Contains("OP")) |
| | | if (input.WorkingProcedure.Length != 4 || !input.WorkingProcedure.Contains("OP")) |
| | | { |
| | | throw Oops.Oh($"修改工件信息失败:传入工序[{input.WorkingProcedure}]不对!"); |
| | | } |
| | |
| | | throw Oops.Oh($"修改工件质量状态失败:工件{item}不存在!"); |
| | | } |
| | | string LogAddRemark = ""; |
| | | if (workPieceInfo.QualityState!= int.Parse(input.QualityState)) |
| | | if (workPieceInfo.QualityState != int.Parse(input.QualityState)) |
| | | { |
| | | LogAddRemark += $"质量信息[{workPieceInfo.QualityState ?? 0}]到[{input.QualityState}]"; |
| | | workPieceInfo.QualityState = int.Parse(input.QualityState); |
| | |
| | | { |
| | | LogAddRemark += $"工件状态 [{workPieceInfo.WorkPieceState}]到[{input.WorkPieceState}]"; |
| | | workPieceInfo.WorkPieceState = int.Parse(input.WorkPieceState); |
| | | if(workPieceInfo.WorkPieceState==(int)EnumWorkPieceState.FinishedProducts) |
| | | if (workPieceInfo.WorkPieceState == (int)EnumWorkPieceState.FinishedProducts) |
| | | { |
| | | workPieceInfo.WorkPieceLastOfflineTime = DateTime.Now; |
| | | } |
| | |
| | | } |
| | | string OP80NewCode = input.OP80NewCode.Trim(); |
| | | var workPieceInfo = await _workPieceInfoRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(OP80NewCode), u => u.OP80NewCode == OP80NewCode||u.WorkPieceID== OP80NewCode) |
| | | .Where(!string.IsNullOrEmpty(OP80NewCode), u => u.OP80NewCode == OP80NewCode || u.WorkPieceID == OP80NewCode) |
| | | .Select(s => new WorkPieceInfoOutput |
| | | { |
| | | Id = s.Id, |
| | |
| | | }).FirstOrDefaultAsync(); |
| | | if (workPieceInfo == null) |
| | | { |
| | | throw Oops.Oh($"OP80打印成品码或工件二维码【{OP80NewCode}】没有找到相关工件信息!"); |
| | | //throw Oops.Oh($"OP80打印成品码或工件二维码【{OP80NewCode}】没有找到相关工件信息!"); |
| | | workPieceInfo = new WorkPieceInfoOutput |
| | | { |
| | | WorkPieceID = OP80NewCode, |
| | | OP80NewCode = OP80NewCode, |
| | | }; |
| | | } |
| | | return workPieceInfo; |
| | | } |
| | |
| | | |
| | | var addOutBoundList = new List<WorkPieceOutbound>(); |
| | | |
| | | var queryWorkPieceIDList = WorkPieceInfoLst.Select(x => x.WorkPieceID).ToList(); |
| | | List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | foreach (var item in WorkPieceInfoLst) |
| | | { |
| | | WorkPieceOutbound itemModel=await _workPieceOutboundRep.FirstOrDefaultAsync(w=>w.WorkPieceID==item.WorkPieceID); |
| | | if (itemModel != null) { |
| | | itemModel.IsDeleted = true; |
| | | itemModel.Remark = itemModel.Remark ?? "" + "二次发货自动撤销发货"; |
| | | await _workPieceOutboundRep.UpdateAsync(itemModel); |
| | | var itemModel = db_itemModelList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID); |
| | | if (itemModel != null) |
| | | { |
| | | //itemModel.IsDeleted = true; |
| | | //itemModel.Remark = itemModel.Remark ?? "" + "二次发货自动撤销发货"; |
| | | //await _workPieceOutboundRep.UpdateAsync(itemModel); |
| | | var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"工件{itemModel.WorkPieceID}已出库,出库时间:{createitme}"); |
| | | } |
| | | var outBoundLog = new WorkPieceOutbound |
| | | { |
| | |
| | | return "出库成功"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 出库统计 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("getOutBoundWorkPieceInfoCount")] |
| | | public async Task<string> GetOutBoundWorkPieceInfoCount() |
| | | { |
| | | DateTimeOffset now = DateTimeOffset.Now; // 获取当前时间,包括时区偏移量 |
| | | DateTimeOffset startOfDay = new DateTimeOffset(now.Year, now.Month, now.Day, 0, 0, 0, now.Offset); // 当天开始时间 |
| | | DateTimeOffset endOfDay = new DateTimeOffset(now.Year, now.Month, now.Day, 23, 59, 59, now.Offset); // 当天结束时间 |
| | | List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => w.CreatedTime >= startOfDay && w.CreatedTime <= endOfDay && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | return db_itemModelList.Count().ToString(); |
| | | } |
| | | |
| | | } |
| | | } |