diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasDefect/DefectOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasDefect/DefectOutput.cs new file mode 100644 index 00000000..dcf2811c --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Dto/BasDefect/DefectOutput.cs @@ -0,0 +1,9 @@ +namespace Tnb.BasicData.Entities.Dto +{ + public class DefectOutput + { + public string id { get; set; } + public string defect_code { get; set; } + public string defect_name { get; set; } + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/BasDefectService.cs b/BasicData/Tnb.BasicData/BasDefectService.cs index 2ee6d6ba..01cd4c26 100644 --- a/BasicData/Tnb.BasicData/BasDefectService.cs +++ b/BasicData/Tnb.BasicData/BasDefectService.cs @@ -5,6 +5,7 @@ using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; using SqlSugar; +using Tnb.BasicData.Entities.Dto; using Tnb.BasicData.Entities; using Tnb.BasicData.Interfaces; @@ -33,11 +34,22 @@ namespace Tnb.BasicData public async Task GetDefectListByProcessId(Dictionary dic) { string processId = dic["processId"]; - return await _repository.AsSugarClient().Queryable() - .LeftJoin((a, b) => a.process_id == b.id) - .LeftJoin((a, b, c) => a.defective_id == c.id) - .Where((a, b, c) => a.process_id == processId) - .Select((a, b, c) => c).ToListAsync(); + var db = _repository.AsSugarClient(); + List defectIds = await db.Queryable().Where(x=>x.process_id==processId).Select(x=>x.defective_id).ToListAsync(); + List defectTypeIds = await db.Queryable().Where(x=>defectIds.Contains(x.id) && x.enabled==1).Select(x=>x.defect_type_id).ToListAsync(); + return await _repository.AsSugarClient().Queryable() + .Where((a) => defectTypeIds.Contains(a.id)) + .Select(a => new + { + defect_type_id = a.id, + defect_type_name = a.defect_type_name, + children = SqlFunc.Subqueryable().Where(x=>x.defect_type_id==a.id && defectIds.Contains(x.id)).ToList(x=>new DefectOutput() + { + id = x.id, + defect_code = x.defect_code, + defect_name = x.defect_name, + }) + }).ToListAsync(); } } } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs index f9e9fd96..07d58f64 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs @@ -49,11 +49,6 @@ public partial class WmsCarryCode : BaseEntity, IWmsCarryEntity /// public decimal codeqty { get; set; } - /// - /// 行号 - /// - public int no { get; set; } - /// /// 是否出库 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index d71a69a9..0a8b4a4c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -36,7 +36,7 @@ namespace Tnb.WarehouseMgr } } } - + [NonAction] protected async Task DoUpdate(WareHouseUpInput input) { if (_stroageMap.ContainsKey(input.loginType)) @@ -44,7 +44,7 @@ namespace Tnb.WarehouseMgr await _stroageMap[input.loginType].Do(input); } } - + [NonAction] public virtual Task ModifyAsync(WareHouseUpInput input) { return Task.CompletedTask; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 812656cc..1c97bda6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -485,7 +485,7 @@ namespace Tnb.WarehouseMgr var carryStatus = multis[i].carry_status; if (multis[i].carry_status == ((int)EnumCarryStatus.空闲).ToString()) { - carryStatus = ((int)EnumCarryStatus.空闲).ToString(); + carryStatus = ((int)EnumCarryStatus.占用).ToString(); } var cStatus = carryStatus.ParseToInt(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = cStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 644d1be2..126a72ec 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -199,6 +199,10 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); //如果是自动单据,需要回更上层系统 } + else { + //任务没有结束,更新状态为工作中 + await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + } } await _db.Ado.CommitTranAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 1641dc39..bea1e56b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Aop.Api.Domain; using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Extension; @@ -223,7 +224,20 @@ namespace Tnb.WarehouseMgr } } } - var isOk = await _wareHouseService.GenPreTask(preTasks, null); + List pretaskCodes = new(); + foreach (var pt in preTasks) + { + var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList(); + var curPreTaskCodes = partCodes.Adapt>(); + curPreTaskCodes.ForEach(x => + { + x.id=SnowflakeIdHelper.NextId(); + x.bill_id = pt.id; + x.create_time = DateTime.Now; + }); + pretaskCodes.AddRange(curPreTaskCodes); + } + var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); @@ -329,6 +343,10 @@ namespace Tnb.WarehouseMgr { osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; } + else + { + osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID; + } } } await _db.Updateable(curOutstockDetails).ExecuteCommandAsync(); @@ -337,6 +355,11 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); //如果是自动单据,需要回更上层系统 } + else + { + //如果没有完成,修改为工作中 + await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + } await _wareCarryService.UpdateNullCarry(carry); } else if (outStatus == EnumOutStatus.分拣出) @@ -359,6 +382,36 @@ namespace Tnb.WarehouseMgr x.create_time = DateTime.Now; }); await _db.Insertable(osCodes).ExecuteCommandAsync(); + // 更新主表 + var detailIds = osCodes.Select(x => x.bill_d_id).ToList(); + var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id)); + var dic = osCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList()); + foreach (var osd in curOutstockDetails) + { + if (dic.ContainsKey(osd.id)) + { + osd.qty += dic[osd.id].Sum(d => d); + if (osd.qty >= osd.pr_qty) + { + osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; + } + else + { + osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID; + } + } + } + await _db.Updateable(curOutstockDetails).ExecuteCommandAsync(); + if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + { + await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + //如果是自动单据,需要回更上层系统 + } + else + { + //如果没有完成,修改为工作中 + await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + } var carryCodes = await _db.Queryable().Where(it => input.carryIds.Contains(it.carry_id)).ToListAsync(); var dicCodeQty = carryCodes.GroupBy(g => g.barcode).ToDictionary(x => x.Key, x => x.First().codeqty); @@ -382,9 +435,12 @@ namespace Tnb.WarehouseMgr { foreach (var pair in dicUpdate) { - WmsCarryCode carryCode = new(); - carryCode.codeqty = pair.Value; - await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).Where(it => it.barcode == pair.Key).ExecuteCommandAsync(); + WmsCarryCode? carryCode = carryCodes.Find(x => x.barcode == pair.Key); + if (carryCode != null) + { + carryCode.codeqty = pair.Value; + await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync(); + } } await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Deleteable().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); @@ -402,7 +458,11 @@ namespace Tnb.WarehouseMgr [nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id, [nameof(WmsPointH.location_id)] = outStockH.location_id, [nameof(WmsCarryD.carry_id)] = input.carryIds.First(), + [nameof(WmsCarryH.carry_code)] = carry.carry_code, [nameof(WmsHandleH.biz_type)] = input.bizTypeId, + [nameof(WmsHandleH.create_id)] = _userManager.UserId, + [nameof(WmsHandleH.create_time)] = DateTime.Now, + [nameof(WmsMoveInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID, [nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(), }; await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index 0dd6eebc..4936c01d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -247,6 +247,7 @@ namespace Tnb.WarehouseMgr if (instockCOdes?.Count > 0) { await _db.Updateable().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCOdes.Select(x => x.bill_d_id).Contains(it.id)).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.data[nameof(WmsHandleH.require_id)].ToString()).ExecuteCommandAsync(); } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index ecc671a9..3a9df542 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -124,7 +124,20 @@ namespace Tnb.WarehouseMgr { await _genPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); } - var isOk = await _wareHouseService.GenPreTask(preTasks, null); + List pretaskCodes = new(); + foreach (var pt in preTasks) + { + var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList(); + var curPreTaskCodes = partCodes.Adapt>(); + curPreTaskCodes.ForEach(x => + { + x.id = SnowflakeIdHelper.NextId(); + x.bill_id = pt.id; + x.create_time = DateTime.Now; + }); + pretaskCodes.AddRange(curPreTaskCodes); + } + var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 34cccb55..1806caf7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -79,27 +79,35 @@ namespace Tnb.WarehouseMgr { if (_dicBizType.ContainsKey(disTask.biz_type)) { - switch (_dicBizType[disTask.biz_type]) - { - case "空载具出库": - case "寄存出库": - case "齐套出库": - case "一般出库": - { - WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; - await DoUpdate(upInput); //回更业务 - + WareHouseUpInput upInput = new() { + loginType = "web", + bizTypeId = disTask.biz_type, + requireId = disTask.require_id, + carryIds = new List { input.carryId }, + distaskCodes = input.distaskCodes }; + await DoUpdate(upInput); //回更业务 + //switch (_dicBizType[disTask.biz_type]) + //{ + // case "空载具出库": + // case "寄存出库": + // case "齐套出库": + // case "一般出库": + // { - } - break; - case "载具移出": - { - WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; - await DoUpdate(upInput); //回更业务 - } - break; + // WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId }, distaskCodes = input.distaskCodes }; + // await DoUpdate(upInput); //回更业务 - } + + // } + // break; + // case "载具移出": + // { + // WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId }, distaskCodes = input.distaskCodes }; + // await DoUpdate(upInput); //回更业务 + // } + // break; + + //} } disTask.is_sign = 1; await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync(); diff --git a/system/Tnb.Systems/System/PrintDevService.cs b/system/Tnb.Systems/System/PrintDevService.cs index 9af13070..98c3d510 100644 --- a/system/Tnb.Systems/System/PrintDevService.cs +++ b/system/Tnb.Systems/System/PrintDevService.cs @@ -90,9 +90,10 @@ public class PrintDevService : IDynamicApiController, ITransient [HttpGet("")] public async Task GetList_Api([FromQuery] PrintDevListInput input) { - var list = await _repository.AsSugarClient().Queryable((a, b, c, d) => - new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId, JoinType.Left, a.Category == d.EnCode)) - .Where((a, b, c, d) => a.DeleteMark == null && d.DictionaryTypeId == "202931027482510597").WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category) + var list = await _repository.AsSugarClient().Queryable((a, b, c, d,e) => + new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId,JoinType.Left,d.EnCode=="printDev", JoinType.Left, a.Category == e.EnCode && d.Id==e.DictionaryTypeId)) + .Where((a, b, c, d,e) => a.DeleteMark == null ) + .WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category) .WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword)) .OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc) .Select((a, b, c, d) => new PrintDevListOutput @@ -119,10 +120,10 @@ public class PrintDevService : IDynamicApiController, ITransient [HttpGet("Selector")] public async Task GetList_Api([FromQuery] string type) { - var list = await _repository.AsSugarClient().Queryable((a, b, c, d) => new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId, JoinType.Left, a.Category == d.EnCode)) - .Where((a, b, c, d) => a.DeleteMark == null && d.DictionaryTypeId == "202931027482510597" && a.EnabledMark == 1).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc) + var list = await _repository.AsSugarClient().Queryable((a, b, c, d,e) => new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId, JoinType.Left, d.EnCode=="printDev", JoinType.Left, a.Category == e.EnCode && d.Id==e.DictionaryTypeId)) + .Where((a, b, c, d) => a.DeleteMark == null && a.EnabledMark == 1).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc) .WhereIF(type.IsNotEmptyOrNull(), (a) => a.Type == type.ParseToInt()) - .Select((a, b, c, d) => new PrintDevListOutput + .Select((a, b, c, d,e) => new PrintDevListOutput { category = a.Category, id = a.Id, @@ -135,7 +136,7 @@ public class PrintDevService : IDynamicApiController, ITransient lastModifyUser = SqlFunc.MergeString(c.RealName, "/", c.Account), sortCode = a.SortCode, type = a.Type, - parentId = d.Id, + parentId = e.Id, }).ToListAsync(); // 数据库分类