This commit is contained in:
qianjiawei
2023-06-29 17:47:44 +08:00
11 changed files with 147 additions and 44 deletions

View File

@@ -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; }
}
}

View File

@@ -5,6 +5,7 @@ using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev; using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using Tnb.BasicData.Entities.Dto;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
using Tnb.BasicData.Interfaces; using Tnb.BasicData.Interfaces;
@@ -33,11 +34,22 @@ namespace Tnb.BasicData
public async Task<dynamic> GetDefectListByProcessId(Dictionary<string, string> dic) public async Task<dynamic> GetDefectListByProcessId(Dictionary<string, string> dic)
{ {
string processId = dic["processId"]; string processId = dic["processId"];
return await _repository.AsSugarClient().Queryable<BasProcessDefective>() var db = _repository.AsSugarClient();
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id) List<string> defectIds = await db.Queryable<BasProcessDefective>().Where(x=>x.process_id==processId).Select(x=>x.defective_id).ToListAsync();
.LeftJoin<BasDefect>((a, b, c) => a.defective_id == c.id) List<string> defectTypeIds = await db.Queryable<BasDefect>().Where(x=>defectIds.Contains(x.id) && x.enabled==1).Select(x=>x.defect_type_id).ToListAsync();
.Where((a, b, c) => a.process_id == processId) return await _repository.AsSugarClient().Queryable<BasDefectType>()
.Select((a, b, c) => c).ToListAsync(); .Where((a) => defectTypeIds.Contains(a.id))
.Select(a => new
{
defect_type_id = a.id,
defect_type_name = a.defect_type_name,
children = SqlFunc.Subqueryable<BasDefect>().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();
} }
} }
} }

View File

@@ -49,11 +49,6 @@ public partial class WmsCarryCode : BaseEntity<string>, IWmsCarryEntity
/// </summary> /// </summary>
public decimal codeqty { get; set; } public decimal codeqty { get; set; }
/// <summary>
/// 行号
/// </summary>
public int no { get; set; }
/// <summary> /// <summary>
/// 是否出库 /// 是否出库
/// </summary> /// </summary>

View File

@@ -36,7 +36,7 @@ namespace Tnb.WarehouseMgr
} }
} }
} }
[NonAction]
protected async Task DoUpdate(WareHouseUpInput input) protected async Task DoUpdate(WareHouseUpInput input)
{ {
if (_stroageMap.ContainsKey(input.loginType)) if (_stroageMap.ContainsKey(input.loginType))
@@ -44,7 +44,7 @@ namespace Tnb.WarehouseMgr
await _stroageMap[input.loginType].Do(input); await _stroageMap[input.loginType].Do(input);
} }
} }
[NonAction]
public virtual Task ModifyAsync(WareHouseUpInput input) public virtual Task ModifyAsync(WareHouseUpInput input)
{ {
return Task.CompletedTask; return Task.CompletedTask;

View File

@@ -485,7 +485,7 @@ namespace Tnb.WarehouseMgr
var carryStatus = multis[i].carry_status; var carryStatus = multis[i].carry_status;
if (multis[i].carry_status == ((int)EnumCarryStatus.).ToString()) if (multis[i].carry_status == ((int)EnumCarryStatus.).ToString())
{ {
carryStatus = ((int)EnumCarryStatus.).ToString(); carryStatus = ((int)EnumCarryStatus.).ToString();
} }
var cStatus = carryStatus.ParseToInt(); var cStatus = carryStatus.ParseToInt();
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = cStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = cStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync();

View File

@@ -199,6 +199,10 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
//如果是自动单据,需要回更上层系统 //如果是自动单据,需要回更上层系统
} }
else {
//任务没有结束,更新状态为工作中
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
}
} }
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Aop.Api.Domain;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension; using JNPF.Common.Extension;
@@ -223,7 +224,20 @@ namespace Tnb.WarehouseMgr
} }
} }
} }
var isOk = await _wareHouseService.GenPreTask(preTasks, null); List<WmsPretaskCode> pretaskCodes = new();
foreach (var pt in preTasks)
{
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
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(); GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
@@ -329,6 +343,10 @@ namespace Tnb.WarehouseMgr
{ {
osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
} }
else
{
osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID;
}
} }
} }
await _db.Updateable(curOutstockDetails).ExecuteCommandAsync(); await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
@@ -337,6 +355,11 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
//如果是自动单据,需要回更上层系统 //如果是自动单据,需要回更上层系统
} }
else
{
//如果没有完成,修改为工作中
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
}
await _wareCarryService.UpdateNullCarry(carry); await _wareCarryService.UpdateNullCarry(carry);
} }
else if (outStatus == EnumOutStatus.) else if (outStatus == EnumOutStatus.)
@@ -359,6 +382,36 @@ namespace Tnb.WarehouseMgr
x.create_time = DateTime.Now; x.create_time = DateTime.Now;
}); });
await _db.Insertable(osCodes).ExecuteCommandAsync(); 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<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
//如果是自动单据,需要回更上层系统
}
else
{
//如果没有完成,修改为工作中
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
}
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => input.carryIds.Contains(it.carry_id)).ToListAsync(); var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => input.carryIds.Contains(it.carry_id)).ToListAsync();
var dicCodeQty = carryCodes.GroupBy(g => g.barcode).ToDictionary(x => x.Key, x => x.First().codeqty); 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) foreach (var pair in dicUpdate)
{ {
WmsCarryCode carryCode = new(); WmsCarryCode? carryCode = carryCodes.Find(x => x.barcode == pair.Key);
carryCode.codeqty = pair.Value; if (carryCode != null)
await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).Where(it => it.barcode == pair.Key).ExecuteCommandAsync(); {
carryCode.codeqty = pair.Value;
await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync();
}
} }
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); await _db.Deleteable<WmsCarryMat>().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync();
@@ -402,7 +458,11 @@ namespace Tnb.WarehouseMgr
[nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id, [nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id,
[nameof(WmsPointH.location_id)] = outStockH.location_id, [nameof(WmsPointH.location_id)] = outStockH.location_id,
[nameof(WmsCarryD.carry_id)] = input.carryIds.First(), [nameof(WmsCarryD.carry_id)] = input.carryIds.First(),
[nameof(WmsCarryH.carry_code)] = carry.carry_code,
[nameof(WmsHandleH.biz_type)] = input.bizTypeId, [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(), [nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(),
}; };
await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput); await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput);

View File

@@ -247,6 +247,7 @@ namespace Tnb.WarehouseMgr
if (instockCOdes?.Count > 0) if (instockCOdes?.Count > 0)
{ {
await _db.Updateable<WmsInstockD>().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<WmsInstockD>().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<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.data[nameof(WmsHandleH.require_id)].ToString()).ExecuteCommandAsync();
} }
} }
} }

View File

@@ -124,7 +124,20 @@ namespace Tnb.WarehouseMgr
{ {
await _genPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); await _genPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
} }
var isOk = await _wareHouseService.GenPreTask(preTasks, null); List<WmsPretaskCode> pretaskCodes = new();
foreach (var pt in preTasks)
{
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
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(); GenPreTaskUpInput genPreTaskAfterUpInput = new();
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();

View File

@@ -79,27 +79,35 @@ namespace Tnb.WarehouseMgr
{ {
if (_dicBizType.ContainsKey(disTask.biz_type)) if (_dicBizType.ContainsKey(disTask.biz_type))
{ {
switch (_dicBizType[disTask.biz_type]) WareHouseUpInput upInput = new() {
{ loginType = "web",
case "空载具出库": bizTypeId = disTask.biz_type,
case "寄存出库": requireId = disTask.require_id,
case "齐套出库": carryIds = new List<string> { input.carryId },
case "一般出库": distaskCodes = input.distaskCodes };
{ await DoUpdate(upInput); //回更业务
WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId } }; //switch (_dicBizType[disTask.biz_type])
await DoUpdate(upInput); //回更业务 //{
// case "空载具出库":
// case "寄存出库":
// case "齐套出库":
// case "一般出库":
// {
// WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId }, distaskCodes = input.distaskCodes };
// await DoUpdate(upInput); //回更业务
} // }
break; // break;
case "载具移出": // case "载具移出":
{ // {
WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId } }; // WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId }, distaskCodes = input.distaskCodes };
await DoUpdate(upInput); //回更业务 // await DoUpdate(upInput); //回更业务
} // }
break; // break;
} //}
} }
disTask.is_sign = 1; disTask.is_sign = 1;
await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync(); await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync();

View File

@@ -90,9 +90,10 @@ public class PrintDevService : IDynamicApiController, ITransient
[HttpGet("")] [HttpGet("")]
public async Task<dynamic> GetList_Api([FromQuery] PrintDevListInput input) public async Task<dynamic> GetList_Api([FromQuery] PrintDevListInput input)
{ {
var list = await _repository.AsSugarClient().Queryable<PrintDevEntity, UserEntity, UserEntity, DictionaryDataEntity>((a, b, c, d) => var list = await _repository.AsSugarClient().Queryable<PrintDevEntity, UserEntity, UserEntity, DictionaryTypeEntity,DictionaryDataEntity>((a, b, c, d,e) =>
new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId, JoinType.Left, a.Category == d.EnCode)) 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 && d.DictionaryTypeId == "202931027482510597").WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category) .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)) .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) .OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
.Select((a, b, c, d) => new PrintDevListOutput .Select((a, b, c, d) => new PrintDevListOutput
@@ -119,10 +120,10 @@ public class PrintDevService : IDynamicApiController, ITransient
[HttpGet("Selector")] [HttpGet("Selector")]
public async Task<dynamic> GetList_Api([FromQuery] string type) public async Task<dynamic> GetList_Api([FromQuery] string type)
{ {
var list = await _repository.AsSugarClient().Queryable<PrintDevEntity, UserEntity, UserEntity, DictionaryDataEntity>((a, b, c, d) => new JoinQueryInfos(JoinType.Left, b.Id == a.CreatorUserId, JoinType.Left, c.Id == a.LastModifyUserId, JoinType.Left, a.Category == d.EnCode)) var list = await _repository.AsSugarClient().Queryable<PrintDevEntity, UserEntity, UserEntity, DictionaryTypeEntity,DictionaryDataEntity>((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 && d.DictionaryTypeId == "202931027482510597" && a.EnabledMark == 1).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc) .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()) .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, category = a.Category,
id = a.Id, id = a.Id,
@@ -135,7 +136,7 @@ public class PrintDevService : IDynamicApiController, ITransient
lastModifyUser = SqlFunc.MergeString(c.RealName, "/", c.Account), lastModifyUser = SqlFunc.MergeString(c.RealName, "/", c.Account),
sortCode = a.SortCode, sortCode = a.SortCode,
type = a.Type, type = a.Type,
parentId = d.Id, parentId = e.Id,
}).ToListAsync(); }).ToListAsync();
// 数据库分类 // 数据库分类