| | |
| | | using Furion.DynamicApiController; |
| | | using System.Text; |
| | | using iWare.Wms.Core.Enum; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | |
| | | namespace iWare.Wms.Application.Service.Pda |
| | | { |
| | |
| | | //[Route("api")] |
| | | [ApiDescriptionSettings("Pda相关接口", Name = "PdaService", Order = 100)] |
| | | [Route("api/[Controller]")] |
| | | [DisableOpLog] |
| | | public class PdaService : IDynamicApiController, ITransient |
| | | { |
| | | private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep; |
| | |
| | | private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep; |
| | | private readonly IRepository<WorkPieceInfoLog, MasterDbContextLocator> _workPieceInfoLogRep; |
| | | private readonly IRepository<WorkPieceOutbound, MasterDbContextLocator> _workPieceOutboundRep; |
| | | private readonly IRepository<WorkPieceOutboundRecord, MasterDbContextLocator> _workPieceOutboundRecordRep; |
| | | private readonly IRepository<WorkPieceUnLine, MasterDbContextLocator> _workPieceUnLineRep; |
| | | |
| | | /// <summary> |
| | | /// 设备基础信息构造函数 |
| | | /// </summary> |
| | | /// <param name="equipmentBaseInfoRep"></param> |
| | | public PdaService( |
| | | IRepository<WorkPieceOutboundRecord, MasterDbContextLocator> workPieceOutboundRecordRep, |
| | | IRepository<WorkPieceUnLine, MasterDbContextLocator> workPieceUnLineRep, |
| | | IRepository<EquipmentBaseInfo, MasterDbContextLocator> equipmentBaseInfoRep, |
| | | IRepository<V_GetEquipmentAlert, MasterDbContextLocator> v_GetEquipmentAlert, |
| | | IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep, |
| | |
| | | IRepository<WorkPieceOutbound, MasterDbContextLocator> workPieceOutboundRep |
| | | ) |
| | | { |
| | | _workPieceOutboundRecordRep = workPieceOutboundRecordRep; |
| | | _workPieceUnLineRep = workPieceUnLineRep; |
| | | _equipmentBaseInfoRep = equipmentBaseInfoRep; |
| | | _v_GetEquipmentAlertRep = v_GetEquipmentAlert; |
| | | _equipmentCurrentMonitorRep = equipmentCurrentMonitorRep; |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpGet("getWorkPieceProcess")] |
| | | [DisableOpLog] |
| | | public async Task<WorkPieceProcessPdaOutput> getWorkPieceProcess([FromQuery] WorkPieceProcessPdaSearch input) |
| | | { |
| | | var workPieceProcesss = await _workPieceProcessRep.DetachedEntities |
| | |
| | | .Select(s => new WorkPieceProcessOutput |
| | | { |
| | | Id = s.a.Id, |
| | | |
| | | JiaJuGongWei = s.a.JiaJuGongWei, |
| | | |
| | | DataCapturePointCname = s.a.DataCapturePointCname, |
| | | UpdateDataCapturePointCname = s.a.UpdateDataCapturePointCname, |
| | | QualityNoOkReason = s.a.QualityNoOkReason, |
| | | CreateUserName = s.a.CreatedUserName, |
| | | UpdatedUserName = s.a.UpdatedUserName, |
| | | |
| | | WorkPieceID = s.a.WorkPieceID, |
| | | WorkingProcedureCurrent = s.a.WorkingProcedureCurrent, |
| | | EquipmentID = s.a.EquipmentID, |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet("getWorkPieceByOP80NewCode")] |
| | | [DisableOpLog] |
| | | [AllowAnonymous] |
| | | public async Task<WorkPieceInfoOutput> getWorkPieceByOP80NewCode([FromQuery] WorkPieceByOP80NewCodeInputSearch input) |
| | | { |
| | | |
| | | if (string.IsNullOrEmpty(input.OP80NewCode)) |
| | | { |
| | | throw Oops.Oh($"请输入OP80打印成品码或二维码!"); |
| | | throw Oops.Oh($"请输入成品码或工件码!"); |
| | | } |
| | | if (input.OP80NewCode.Length > 22) |
| | | { |
| | | throw Oops.Oh($"工件码或成品码{input.OP80NewCode}长度不正确!"); |
| | | } |
| | | string OP80NewCode = input.OP80NewCode.Trim(); |
| | | var workPieceInfo = await _workPieceInfoRep.DetachedEntities |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("outBoundWorkPiece")] |
| | | [DisableOpLog] |
| | | [UnitOfWork] |
| | | public async Task<string> outBoundWorkPiece([FromBody] OutBoundInput input) |
| | | { |
| | | |
| | | if (input.Password == null || !input.Password.Equals("123456")) |
| | | { |
| | | throw Oops.Oh("修改工件质量状态失败:密码输入错误!"); |
| | | } |
| | | //if (input.Password == null || !input.Password.Equals("123456")) |
| | | //{ |
| | | // throw Oops.Oh("修改工件质量状态失败:密码输入错误!"); |
| | | //} |
| | | if (input.WorkPieceInfoLst.Count < 1) |
| | | { |
| | | throw Oops.Oh("工件出库失败:数据不能为空!"); |
| | | throw Oops.Oh("工件入库失败:数据不能为空!"); |
| | | } |
| | | |
| | | List<WorkPieceInfoOutput> WorkPieceInfoLst = input.WorkPieceInfoLst; |
| | | List<OutBoundDetailsInput> WorkPieceInfoLst = input.WorkPieceInfoLst; |
| | | |
| | | 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(); |
| | | var queryOP80NewCodeList = WorkPieceInfoLst.Select(x => x.OP80NewCode).ToList(); |
| | | List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync(); |
| | | List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | var addOutBoundLogList = new List<WorkPieceOutboundRecord>(); |
| | | |
| | | foreach (var item in WorkPieceInfoLst) |
| | | { |
| | | var itemModel = db_itemModelList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID); |
| | | var itemModel = db_itemModelList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode && w.IsDeleted == false); |
| | | 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}"); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已出库,出库时间:{createitme}"); |
| | | |
| | | //*/ |
| | | |
| | | //不再提示出来,自动忽略 【Editby shaocx,2024-09-04】 |
| | | continue; |
| | | } |
| | | var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (workPiece != null) |
| | | { |
| | | workPiece.OutPerson = CurrentUserInfo.Name; |
| | | workPiece.OutRemark = "撤销工件入库"; |
| | | workPiece.OutTime = DateTime.Now; |
| | | workPiece.IsOut = false; |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | var outBoundLog = new WorkPieceOutbound |
| | | { |
| | | WorkPieceID = item.WorkPieceID, |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | WorkPieceOutboundTime = DateTime.Now, |
| | | WorkPieceOutboundUserId = CurrentUserInfo.UserId, |
| | |
| | | }; |
| | | addOutBoundList.Add(outBoundLog); |
| | | |
| | | var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID); |
| | | if (workPiece != null) |
| | | var outBoundLogRecord = new WorkPieceOutboundRecord |
| | | { |
| | | workPiece.OutPerson = CurrentUserInfo.Name; |
| | | workPiece.OutRemark = "撤销工件出库"; |
| | | workPiece.OutTime = DateTime.Now; |
| | | workPiece.IsOut = false; |
| | | OperationType = OutboundOperationType.入库.ToString(), |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | |
| | | //CarNo = input.CarNo, |
| | | Remark = "工件入库", |
| | | |
| | | }; |
| | | addOutBoundLogList.Add(outBoundLogRecord); |
| | | |
| | | |
| | | } |
| | | await _workPieceOutboundRep.InsertAsync(addOutBoundList); |
| | | |
| | | await _workPieceOutboundRecordRep.InsertAsync(addOutBoundLogList); |
| | | |
| | | return "出库成功"; |
| | | } |
| | | |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("getOutBoundWorkPieceInfoCount")] |
| | | [DisableOpLog] |
| | | public async Task<string> GetOutBoundWorkPieceInfoCount() |
| | | { |
| | | DateTimeOffset now = DateTimeOffset.Now; // 获取当前时间,包括时区偏移量 |
| | |
| | | return db_itemModelList.Count().ToString(); |
| | | } |
| | | |
| | | |
| | | #region 新版 下线、出库执行 |
| | | |
| | | /// <summary> |
| | | /// 下线执行 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("unLineWorkPiece")] |
| | | [DisableOpLog] |
| | | [UnitOfWork] |
| | | public async Task<string> unLineWorkPiece([FromBody] UnLineInput input) |
| | | { |
| | | if (input.WorkPieceInfoLst.Count < 1) |
| | | { |
| | | throw Oops.Oh("数据不能为空!"); |
| | | } |
| | | if (input.CarNo == null || input.CarNo.Equals("")) |
| | | { |
| | | throw Oops.Oh("小车码必须输入!"); |
| | | } |
| | | |
| | | List<UnBoundDetailsInput> WorkPieceInfoLst = input.WorkPieceInfoLst; |
| | | |
| | | var addOutBoundList = new List<WorkPieceOutbound>(); |
| | | var addOutBoundLogList = new List<WorkPieceOutboundRecord>(); |
| | | |
| | | var queryOP80NewCodeList = WorkPieceInfoLst.Select(x => x.OP80NewCode).ToList(); |
| | | List<WorkPieceOutbound> db_WorkPieceOutboundList = await _workPieceOutboundRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | foreach (var item in WorkPieceInfoLst) |
| | | { |
| | | var itemModel = db_WorkPieceOutboundList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (itemModel != null) |
| | | { |
| | | if (itemModel.UnLineStage == PieceUnLineStage.已出库) |
| | | { |
| | | var createitme = itemModel.WorkPieceOutboundTime == null ? "" : (((DateTimeOffset)itemModel.WorkPieceOutboundTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已出库,出库时间:{createitme}"); |
| | | } |
| | | if (itemModel.UnLineStage == PieceUnLineStage.已下线) |
| | | { |
| | | var createitme = itemModel.WorkPieceUnLineTime == null ? "" : (((DateTimeOffset)itemModel.WorkPieceUnLineTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已下线,下线时间:{createitme}"); |
| | | } |
| | | } |
| | | var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (workPiece != null) |
| | | { |
| | | |
| | | workPiece.OutRemark = "工件下线"; |
| | | workPiece.UnLineStage = PieceUnLineStage.已下线; |
| | | workPiece.UnLineStageName = PieceUnLineStage.已下线.ToString(); |
| | | workPiece.WorkPieceUnLineTime = DateTime.Now; |
| | | workPiece.WorkPieceUnLineUserId = CurrentUserInfo.UserId; |
| | | workPiece.WorkPieceUnLineUserName = CurrentUserInfo.Name; |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | var outBound = new WorkPieceOutbound |
| | | { |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | WorkPieceOutboundTime = DateTime.Now, |
| | | WorkPieceOutboundUserId = CurrentUserInfo.UserId, |
| | | WorkPieceOutboundUserName = CurrentUserInfo.Name, |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | UnLineStage = PieceUnLineStage.已下线, |
| | | UnLineStageName = PieceUnLineStage.已下线.ToString(), |
| | | WorkPieceUnLineTime = DateTime.Now, |
| | | WorkPieceUnLineUserId = CurrentUserInfo.UserId, |
| | | WorkPieceUnLineUserName = CurrentUserInfo.Name, |
| | | CarNo = input.CarNo, |
| | | Remark = "工件下线", |
| | | |
| | | }; |
| | | addOutBoundList.Add(outBound); |
| | | |
| | | var outBoundLog = new WorkPieceOutboundRecord |
| | | { |
| | | OperationType = OutboundOperationType.下线.ToString(), |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | |
| | | CarNo = input.CarNo, |
| | | Remark = "工件下线", |
| | | |
| | | }; |
| | | addOutBoundLogList.Add(outBoundLog); |
| | | |
| | | |
| | | |
| | | } |
| | | await _workPieceOutboundRep.InsertAsync(addOutBoundList); |
| | | await _workPieceOutboundRecordRep.InsertAsync(addOutBoundLogList); |
| | | |
| | | return "下线成功"; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 出库执行 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("outStoreWorkPiece")] |
| | | [DisableOpLog] |
| | | [UnitOfWork] |
| | | public async Task<string> outStoreWorkPiece([FromBody] OutStoreInput input) |
| | | { |
| | | if (input.CarNo == null || input.CarNo.Equals("")) |
| | | { |
| | | throw Oops.Oh("小车码必须输入!"); |
| | | } |
| | | |
| | | |
| | | var updateOutBoundList = new List<WorkPieceOutbound>(); |
| | | var addOutBoundLogList = new List<WorkPieceOutboundRecord>(); |
| | | |
| | | List<WorkPieceOutbound> db_WorkPieceOutboundList = await _workPieceOutboundRep.Where(w => |
| | | w.CarNo == input.CarNo |
| | | && w.UnLineStage == PieceUnLineStage.已下线 |
| | | && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | if (db_WorkPieceOutboundList?.Count == 0) |
| | | { |
| | | throw Oops.Oh("没有可出库的数据!"); |
| | | } |
| | | |
| | | |
| | | var queryOP80NewCodeList = db_WorkPieceOutboundList.Select(x => x.OP80NewCode).ToList(); |
| | | |
| | | List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | foreach (var item in db_WorkPieceOutboundList) |
| | | { |
| | | var itemModel = db_WorkPieceOutboundList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (itemModel != null) |
| | | { |
| | | if (itemModel.UnLineStage == PieceUnLineStage.已出库) |
| | | { |
| | | var createitme = itemModel.WorkPieceOutboundTime == null ? "" : (((DateTimeOffset)itemModel.WorkPieceOutboundTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已出库,出库时间:{createitme}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}没有下线数据"); |
| | | } |
| | | var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (workPiece != null) |
| | | { |
| | | |
| | | workPiece.OutRemark = "工件出库"; |
| | | workPiece.UnLineStage = PieceUnLineStage.已出库; |
| | | workPiece.UnLineStageName = PieceUnLineStage.已出库.ToString(); |
| | | workPiece.OutTime = DateTime.Now; |
| | | workPiece.OutPerson = CurrentUserInfo.Name; |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | |
| | | item.UnLineStage = PieceUnLineStage.已出库; |
| | | item.UnLineStageName = PieceUnLineStage.已出库.ToString(); |
| | | item.WorkPieceUnLineTime = DateTime.Now; |
| | | item.WorkPieceUnLineUserId = CurrentUserInfo.UserId; |
| | | item.WorkPieceUnLineUserName = CurrentUserInfo.Name; |
| | | updateOutBoundList.Add(item); |
| | | |
| | | var outBoundLog = new WorkPieceOutboundRecord |
| | | { |
| | | OperationType = OutboundOperationType.出库.ToString(), |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | |
| | | CarNo = input.CarNo, |
| | | Remark = "工件出库", |
| | | |
| | | }; |
| | | addOutBoundLogList.Add(outBoundLog); |
| | | |
| | | |
| | | |
| | | } |
| | | await _workPieceOutboundRep.UpdateAsync(updateOutBoundList); |
| | | await _workPieceOutboundRecordRep.InsertAsync(addOutBoundLogList); |
| | | |
| | | return "出库成功"; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 下线撤回/出库撤回 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("unLineWorkPieceRollback")] |
| | | [DisableOpLog] |
| | | [UnitOfWork] |
| | | public async Task<string> unLineWorkPieceRollback([FromBody] UnLineRoolbackInput input) |
| | | { |
| | | if (input.WorkPieceInfoLst.Count < 1) |
| | | { |
| | | throw Oops.Oh("数据不能为空!"); |
| | | } |
| | | if (!(input.Flag == 1 || input.Flag == 2)) |
| | | { |
| | | throw Oops.Oh("标记不正确!"); |
| | | } |
| | | var remark = "工件下线撤回"; |
| | | if (input.Flag == 2) |
| | | { |
| | | remark = "工件出库撤回"; |
| | | } |
| | | |
| | | List<UnBoundDetailsInput> WorkPieceInfoLst = input.WorkPieceInfoLst; |
| | | |
| | | var removeOutBoundList = new List<WorkPieceOutbound>(); |
| | | var addOutBoundLogList = new List<WorkPieceOutboundRecord>(); |
| | | |
| | | var queryOP80NewCodeList = WorkPieceInfoLst.Select(x => x.OP80NewCode).ToList(); |
| | | List<WorkPieceOutbound> db_WorkPieceOutboundList = await _workPieceOutboundRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryOP80NewCodeList.Contains(w.OP80NewCode) && w.IsDeleted == false).ToListAsync(); |
| | | |
| | | foreach (var item in WorkPieceInfoLst) |
| | | { |
| | | var itemModel = db_WorkPieceOutboundList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (itemModel != null) |
| | | { |
| | | if (input.Flag == 1 && itemModel.UnLineStage == PieceUnLineStage.已出库) |
| | | { |
| | | var createitme = itemModel.WorkPieceOutboundTime == null ? "" : (((DateTimeOffset)itemModel.WorkPieceOutboundTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已出库,出库时间:{createitme}"); |
| | | } |
| | | if (input.Flag == 2 && itemModel.UnLineStage == PieceUnLineStage.已下线) |
| | | { |
| | | var createitme = itemModel.WorkPieceUnLineTime == null ? "" : (((DateTimeOffset)itemModel.WorkPieceUnLineTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}已下线,下线时间:{createitme}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw Oops.Oh($"成品码{itemModel.OP80NewCode}没有下线出库数据"); |
| | | } |
| | | var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.OP80NewCode == item.OP80NewCode); |
| | | if (workPiece != null) |
| | | { |
| | | workPiece.OutRemark = remark; |
| | | |
| | | if (input.Flag == 1) |
| | | { |
| | | workPiece.UnLineStage = null; |
| | | workPiece.UnLineStageName = ""; |
| | | workPiece.WorkPieceUnLineTime = null; |
| | | workPiece.WorkPieceUnLineUserId = null; |
| | | workPiece.WorkPieceUnLineUserName = ""; |
| | | } |
| | | else |
| | | { |
| | | workPiece.UnLineStage = PieceUnLineStage.已下线; |
| | | workPiece.UnLineStageName = PieceUnLineStage.已下线.ToString(); |
| | | workPiece.WorkPieceUnLineTime = DateTime.Now; |
| | | workPiece.WorkPieceUnLineUserId = CurrentUserInfo.UserId; |
| | | workPiece.WorkPieceUnLineUserName = CurrentUserInfo.Name; |
| | | } |
| | | |
| | | |
| | | await _workPieceInfoRep.UpdateAsync(workPiece); |
| | | } |
| | | |
| | | |
| | | removeOutBoundList.Add(itemModel); |
| | | |
| | | var outBoundLog = new WorkPieceOutboundRecord |
| | | { |
| | | OperationType = input.Flag == 1 ? OutboundOperationType.撤销下线.ToString() : OutboundOperationType.撤销出库.ToString(), |
| | | WorkPieceID = workPiece?.WorkPieceID, |
| | | OP80NewCode = item.OP80NewCode, |
| | | |
| | | CreatedUserId = CurrentUserInfo.UserId, |
| | | CreatedUserName = CurrentUserInfo.Name, |
| | | |
| | | CarNo = itemModel.CarNo, |
| | | Remark = remark, |
| | | |
| | | }; |
| | | addOutBoundLogList.Add(outBoundLog); |
| | | |
| | | |
| | | |
| | | } |
| | | await _workPieceOutboundRep.DeleteAsync(removeOutBoundList); |
| | | await _workPieceOutboundRecordRep.InsertAsync(addOutBoundLogList); |
| | | |
| | | return "操作成功"; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 出库统计 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost("getOutBoundWorkPieceInfoCountList")] |
| | | [DisableOpLog] |
| | | public async Task<List<OutBoundWorkPieceInfoCountOutput>> GetOutBoundWorkPieceInfoCountList([FromBody] OutBoundWorkPieceInfoCountInput input) |
| | | { |
| | | /* |
| | | //测试 |
| | | List<OutBoundWorkPieceInfoCountOutput> outBoundWorkPieceInfoCountOutputs = new List<OutBoundWorkPieceInfoCountOutput>(); |
| | | outBoundWorkPieceInfoCountOutputs.Add(new OutBoundWorkPieceInfoCountOutput() |
| | | { |
| | | Count = 10, |
| | | WorkPieceOutboundUserName = "AAA" |
| | | }); |
| | | outBoundWorkPieceInfoCountOutputs.Add(new OutBoundWorkPieceInfoCountOutput() |
| | | { |
| | | Count = 99, |
| | | WorkPieceOutboundUserName = "BBb" |
| | | }); |
| | | return outBoundWorkPieceInfoCountOutputs; |
| | | //*/ |
| | | |
| | | |
| | | //DateTimeOffset now = DateTimeOffset.Now; // 获取当前时间,包括时区偏移量 |
| | | DateTimeOffset now = input.Date; // 获取当前时间,包括时区偏移量 |
| | | 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(); |
| | | //汇总分组 |
| | | var groupList = db_itemModelList.GroupBy(g => g.WorkPieceOutboundUserName).Select(s => new OutBoundWorkPieceInfoCountOutput() |
| | | { |
| | | WorkPieceOutboundUserName = s.Key, |
| | | Count = s.ToList().Count |
| | | }).ToList(); |
| | | return groupList; |
| | | //*/ |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |