1
This commit is contained in:
16
BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
Normal file
16
BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
public static class WebApiConst
|
||||
{
|
||||
#region wms
|
||||
|
||||
//mes生产入库接口
|
||||
public const string MES_CREATE_INSTOCK = "/api/wms/wms-in-stock/mes-create-instock";
|
||||
|
||||
//载具签收接口
|
||||
public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign";
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class PrdInstockInput
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string bill_type { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 载具编号
|
||||
/// </summary>
|
||||
public string carry_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 起始库位编号
|
||||
/// </summary>
|
||||
public string location_code { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检验(0-未检 1-已检)
|
||||
/// </summary>
|
||||
public int is_check { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子表明细
|
||||
/// </summary>
|
||||
public List<Dictionary<string,string>> details { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public partial class PrdInstockD : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public string quantity { get; set; } = string.Empty;
|
||||
public int quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次
|
||||
@@ -49,4 +49,9 @@ public partial class PrdInstockD : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string barcode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产提报id
|
||||
/// </summary>
|
||||
public string report_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
@@ -38,16 +38,12 @@ public partial class PrdInstockH : BaseEntity<string>
|
||||
/// 起始库位编号
|
||||
/// </summary>
|
||||
public string location_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 来源单据ID
|
||||
/// </summary>
|
||||
public string source_id { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检验(0-未检 1-已检)
|
||||
/// </summary>
|
||||
public string is_check { get; set; } = string.Empty;
|
||||
public int is_check { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
@@ -6,6 +8,13 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
public interface IPrdInstockService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 生产入库报错
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(PrdInstockInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 入库申请同步
|
||||
/// </summary>
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.ClearScript.Util.Web;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
@@ -16,6 +19,7 @@ using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.BasicData;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -29,20 +33,20 @@ namespace Tnb.ProductionMgr
|
||||
private readonly ISqlSugarRepository<PrdFeedingH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
|
||||
// private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
|
||||
|
||||
|
||||
|
||||
public PrdFeedingService(
|
||||
ISqlSugarRepository<PrdFeedingH> repository,
|
||||
IBillRullService billRullService,
|
||||
WmsSignForDeliveryService wmsSignForDeliveryService,
|
||||
// WmsSignForDeliveryService wmsSignForDeliveryService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_wmsSignForDeliveryService = _wmsSignForDeliveryService;
|
||||
// _wmsSignForDeliveryService = _wmsSignForDeliveryService;
|
||||
_billRullService = billRullService;
|
||||
}
|
||||
|
||||
@@ -143,12 +147,12 @@ namespace Tnb.ProductionMgr
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code ?? "",
|
||||
});
|
||||
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
// {
|
||||
// org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
// create_id = _userManager.UserId,
|
||||
// carry_code = input.carry_code ?? "",
|
||||
// });
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
@@ -257,12 +261,26 @@ namespace Tnb.ProductionMgr
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
// {
|
||||
// org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
// create_id = _userManager.UserId,
|
||||
// carry_code = input.carry_code ?? "",
|
||||
// });
|
||||
|
||||
var mesCarrySignInput = new MESCarrySignInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code ?? "",
|
||||
});
|
||||
};
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.RemoteRequest;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.BasicData;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -19,18 +31,112 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
private readonly ISqlSugarRepository<PrdInstockH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
|
||||
public PrdInstockService(
|
||||
ISqlSugarRepository<PrdInstockH> repository,
|
||||
IBillRullService billRullService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(PrdInstockInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
|
||||
PrdInstockH prdInstockH = null;
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
prdInstockH = new PrdInstockH()
|
||||
{
|
||||
bill_type = input.bill_type,
|
||||
bill_date = DateTime.Now,
|
||||
create_id = _userManager.UserId,
|
||||
location_code = input.location_code,
|
||||
carry_code = input.carry_code,
|
||||
is_check = input.is_check,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
warehouse_id = location?.wh_id,
|
||||
status = 0,
|
||||
};
|
||||
|
||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
prdInstockDs.Add(new PrdInstockD()
|
||||
{
|
||||
instock_id = prdInstockH.id,
|
||||
report_id = item.ContainsKey("report_id") ? item["report_id"] : "",
|
||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
||||
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
||||
quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||
});
|
||||
}
|
||||
|
||||
await _repository.InsertAsync(prdInstockH);
|
||||
|
||||
if (prdInstockDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
|
||||
mesCreateInstockInput.instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = input.bill_type,
|
||||
warehouse_id = location?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code,
|
||||
location_code = input.location_code,
|
||||
is_check = input.is_check,
|
||||
};
|
||||
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
|
||||
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
|
||||
{
|
||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
||||
pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||
});
|
||||
|
||||
mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
|
||||
{
|
||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
||||
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
||||
codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||
});
|
||||
}
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
|
||||
Console.WriteLine(sendResult);
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr\Tnb.WarehouseMgr.csproj" />
|
||||
<ProjectReference Include="..\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -555,20 +555,13 @@ namespace Tnb.WarehouseMgr
|
||||
//根据载具ID,更新是否锁定和赋值起始库位
|
||||
if (setCarryColumnsExp != null)
|
||||
{
|
||||
if (input.CarryIds?.Count > 0)
|
||||
{
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(setCarryColumnsExp).Where(it => input.CarryIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(setCarryColumnsExp).Where(it => it.id == input.CarryId).ExecuteCommandAsync();
|
||||
}
|
||||
Expression<Func<WmsCarryH, bool>> whereExp = input.CarryIds?.Count > 0 ? it => input.CarryIds.Contains(it.id) : it => it.id == input.CarryId;
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(setCarryColumnsExp).Where(whereExp).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
//根据所有库位更新库位的锁定状态为“锁定”
|
||||
if (setLocaionColumbExp != null)
|
||||
if (setLocaionColumbExp != null && input.LocationIds?.Count > 0)
|
||||
{
|
||||
await _db.Updateable<BasLocation>().SetColumns(setLocaionColumbExp).Where(it => input.LocationIds!.Contains(it.id)).ExecuteCommandAsync();
|
||||
await _db.Updateable<BasLocation>().SetColumns(setLocaionColumbExp).Where(it => input.LocationIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Tnb.WarehouseMgr
|
||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||
.Select(x =>
|
||||
{
|
||||
WmsCarryMat? carryMat = x.FirstOrDefault();
|
||||
WmsCarryMat carryMat = new();
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
@@ -353,11 +353,19 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
List<WmsCarryMat> carryMats = new();
|
||||
List<WmsCarryCode> carryCodes = new();
|
||||
var whereExp = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
|
||||
.And((a, b, c) => a.is_lock == 0)
|
||||
.And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
|
||||
.And((a, b, c) => a.status == (int)EnumCarryStatus.占用)
|
||||
.And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString());
|
||||
|
||||
foreach (var os in outStockDList)
|
||||
{
|
||||
whereExp.And((a, b, c) => b.material_id == os.material_id)
|
||||
.AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch);
|
||||
|
||||
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||
.Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用 && c.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch)
|
||||
.Where(whereExp.ToExpression())
|
||||
.Select<WmsCarryCode>()
|
||||
.ToListAsync();
|
||||
if (carryCodesPart?.Count > 0)
|
||||
@@ -399,7 +407,7 @@ namespace Tnb.WarehouseMgr
|
||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||
.Select(x =>
|
||||
{
|
||||
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
||||
WmsCarryMat carryMat = new();
|
||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||
return carryMat;
|
||||
})
|
||||
@@ -435,10 +443,8 @@ namespace Tnb.WarehouseMgr
|
||||
List<string> locIds = new();
|
||||
foreach (var carry in carrys)
|
||||
{
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outstock.location_id.ToString());
|
||||
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outstock.location_id.ToString());
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task PackSortingByAdd()
|
||||
public async Task PackSortingByAdd(WmsCarryMat? carryMat)
|
||||
{
|
||||
var setSortings = await _db.Queryable<WmsSetsortingH>()
|
||||
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq)
|
||||
@@ -142,10 +142,11 @@ namespace Tnb.WarehouseMgr
|
||||
List<WmsPretaskH> preTasks = new();
|
||||
List<string> locIds = new();
|
||||
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
||||
if (carrys.Length > 6)
|
||||
var mid = 6;
|
||||
if (carrys.Length > mid)
|
||||
{
|
||||
var leftCarrys = carrys[..6];
|
||||
var rightCarrys = carrys[6..];
|
||||
var leftCarrys = carrys[..mid];
|
||||
var rightCarrys = carrys[mid..];
|
||||
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
|
||||
}
|
||||
@@ -167,7 +168,7 @@ namespace Tnb.WarehouseMgr
|
||||
pretaskCodes.AddRange(curPreTaskCodes);
|
||||
}
|
||||
await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it=> it.id == singleSorting.id).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == singleSorting.id).ExecuteCommandAsync();
|
||||
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
||||
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
||||
@@ -298,7 +299,7 @@ namespace Tnb.WarehouseMgr
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
if (carry != null)
|
||||
{
|
||||
if (carry!.location_id!.IsNotEmptyOrNull())
|
||||
if (carry.location_id?.IsNotEmptyOrNull() ?? false)
|
||||
{
|
||||
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.空闲).ToString() }).Where(it => it.id == carry.location_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ namespace Tnb.WarehouseMgr
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
var firstCarry = carrys.FirstOrDefault();
|
||||
GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry!.id! };
|
||||
GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry?.id };
|
||||
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 }, null!);
|
||||
ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID;
|
||||
ko.carry_id = firstCarry.id;
|
||||
ko.carry_code = firstCarry.carry_code;
|
||||
ko.carry_id = firstCarry?.id;
|
||||
ko.carry_code = firstCarry?.carry_code;
|
||||
await _db.Updateable(ko).UpdateColumns(it => new { it.status, it.carry_id, it.carry_code }).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
@@ -172,7 +172,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
var sPoint = it.FirstOrDefault();
|
||||
var ePoint = it.LastOrDefault();
|
||||
|
||||
|
||||
WmsPretaskH preTask = new();
|
||||
preTask.org_id = _userManager.User.OrganizeId;
|
||||
preTask.startlocation_id = sPoint?.location_id!;
|
||||
@@ -184,7 +184,7 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = ko.biz_type;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||
preTask.carry_id = ko!.carry_id!;
|
||||
preTask.carry_code = ko!.carry_code!;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
|
||||
@@ -22,74 +22,80 @@ namespace Tnb.TaskScheduler.Listener
|
||||
/// <summary>
|
||||
/// 生成质检任务
|
||||
/// </summary>
|
||||
public class QcTaskTimeWorker //: ISpareTimeWorker
|
||||
public class QcTaskTimeWorker : ISpareTimeWorker
|
||||
{
|
||||
private ISqlSugarClient repository => App.GetService<ISqlSugarClient>();
|
||||
private ISqlSugarRepository<QcCheckPlanH> repository => App.GetService<ISqlSugarRepository<QcCheckPlanH>>();
|
||||
|
||||
//[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||
[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||
public async void CreateTask(SpareTimer timer, long count)
|
||||
{
|
||||
var timeTaskEntity = await repository.Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
|
||||
var PlanH = await repository.Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await repository.Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
|
||||
if (PlanH == null || PlanDs.Count == 0)
|
||||
return;
|
||||
var PlanMaterials = repository.Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToList();
|
||||
var PlanProcesss = repository.Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToList();
|
||||
var PlanWork = repository.Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToList();
|
||||
//物料工序工位不能同时为空
|
||||
if (PlanMaterials.Count == 0 && PlanProcesss.Count == 0 && PlanWork.Count == 0)
|
||||
return;
|
||||
var PrdMoTasks = await repository.Queryable<PrdMoTask>()
|
||||
.WhereIF(PlanMaterials.Count > 0, p => PlanMaterials.Contains(p.material_id))
|
||||
.WhereIF(PlanProcesss.Count > 0, p => PlanProcesss.Contains(p.process_id))
|
||||
.WhereIF(PlanWork.Count > 0, p => PlanWork.Contains(p.workstation_id))
|
||||
.Where(p => p.mo_task_status == "InProgress")//进行中
|
||||
.ToListAsync();
|
||||
|
||||
var DictionaryType = await repository.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
foreach (var PrdMoTask in PrdMoTasks)
|
||||
try
|
||||
{
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
qcCheckExecH.materialid = PrdMoTask.material_id;
|
||||
qcCheckExecH.processid = PrdMoTask.process_id;
|
||||
qcCheckExecH.workid = PrdMoTask.workstation_id;
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
|
||||
var PlanH = await repository.AsSugarClient().Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await repository.AsSugarClient().Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
|
||||
if (PlanH == null || PlanDs.Count == 0)
|
||||
return;
|
||||
var PlanMaterials = repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToList();
|
||||
var PlanProcesss = repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToList();
|
||||
var PlanWork = repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToList();
|
||||
//物料工序工位不能同时为空
|
||||
if (PlanMaterials.Count == 0 && PlanProcesss.Count == 0 && PlanWork.Count == 0)
|
||||
return;
|
||||
var PrdMoTasks = await repository.AsSugarClient().Queryable<PrdMoTask>()
|
||||
.WhereIF(PlanMaterials.Count > 0, p => PlanMaterials.Contains(p.material_id))
|
||||
.WhereIF(PlanProcesss.Count > 0, p => PlanProcesss.Contains(p.process_id))
|
||||
.WhereIF(PlanWork.Count > 0, p => PlanWork.Contains(p.workstation_id))
|
||||
.Where(p => p.mo_task_status == "InProgress")//进行中
|
||||
.ToListAsync();
|
||||
|
||||
var DictionaryType = await repository.AsSugarClient().Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
foreach (var PrdMoTask in PrdMoTasks)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
qcCheckExecH.materialid = PrdMoTask.material_id;
|
||||
qcCheckExecH.processid = PrdMoTask.process_id;
|
||||
qcCheckExecH.workid = PrdMoTask.workstation_id;
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
await repository.AsSugarClient().Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
//只执行一次的 修改EnabledMark字段
|
||||
var InterfaceParameter = comtentModel.parameter.Where(p => p.field == "doonce").FirstOrDefault();
|
||||
if (InterfaceParameter != null && bool.Parse(InterfaceParameter.value))
|
||||
{
|
||||
timeTaskEntity.EnabledMark = 0;
|
||||
await repository.AsSugarClient().Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
SpareTime.Cancel(timeTaskEntity.Id);
|
||||
}
|
||||
await repository.Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
//只执行一次的 修改EnabledMark字段
|
||||
var InterfaceParameter = comtentModel.parameter.Where(p => p.field == "doonce").FirstOrDefault();
|
||||
if (InterfaceParameter != null && bool.Parse(InterfaceParameter.value))
|
||||
{
|
||||
timeTaskEntity.EnabledMark = 0;
|
||||
await repository.Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
SpareTime.Cancel(timeTaskEntity.Id);
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user