This commit is contained in:
2024-05-21 09:26:29 +08:00
24 changed files with 471 additions and 23 deletions

View File

@@ -14,5 +14,10 @@ namespace Tnb.BasicData
/// 报工允许超过工单计划数百分比 例填写10就是10%
/// </summary>
public const string IS_SURPASS_PERCENTAGE = "is_surpass_percentage";
/// <summary>
/// 域名
/// </summary>
public const string DOMAIN = "domain";
}
}

View File

@@ -78,6 +78,15 @@ namespace Tnb.BasicData.Entities.Dto
/// Nullable:True
/// </summary>
public string? version { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}
}

View File

@@ -63,5 +63,14 @@
/// 生产bom工序id
/// </summary>
public string? mbom_process_id { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}
}

View File

@@ -73,5 +73,13 @@ public partial class BasEbomD : BaseEntity<string>
/// 工艺路线名称
/// </summary>
public string? route_name { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}

View File

@@ -48,5 +48,14 @@ public partial class BasMbomInput : BaseEntity<string>
/// 单位id
/// </summary>
public string? unit_id { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}

View File

@@ -48,5 +48,14 @@ public partial class BasMbomOutput : BaseEntity<string>
/// 单位id
/// </summary>
public string? unit_id { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}

View File

@@ -104,6 +104,8 @@ namespace Tnb.BasicData
feeding_control = a.feeding_control,
loss_rate = a.loss_rate,
quantity = a.quantity,
molecule = a.molecule,
denominator = a.denominator,
require_weight = a.require_weight,
route_name = e.name,
version = d.version,
@@ -134,6 +136,8 @@ namespace Tnb.BasicData
feeding_control = a.feeding_control,
loss_rate = a.loss_rate,
quantity = a.quantity,
molecule = a.molecule,
denominator = a.denominator,
require_weight = a.require_weight,
route_name = e.name,
version = d.version,

View File

@@ -648,6 +648,8 @@ namespace Tnb.BasicData
process_id = process?.process_id ?? "",
material_id = input.material_id,
num = input.num,
molecule = input.molecule,
denominator = input.denominator,
org_id = orgId,
unit_id = input.unit_id,
});
@@ -667,6 +669,8 @@ namespace Tnb.BasicData
process_id = process?.process_id ?? "",
material_id = output.material_id,
num = output.num,
molecule = output.molecule,
denominator = output.denominator,
org_id = orgId,
unit_id = output.unit_id,
});
@@ -765,6 +769,8 @@ namespace Tnb.BasicData
process_id = process?.process_id ?? "",
material_id = input.material_id,
num = input.num,
molecule = input.molecule,
denominator = input.denominator,
org_id = orgId,
unit_id = input.unit_id,
});
@@ -784,6 +790,8 @@ namespace Tnb.BasicData
process_id = process?.process_id ?? "",
material_id = output.material_id,
num = output.num,
molecule = output.molecule,
denominator = output.denominator,
org_id = orgId,
unit_id = output.unit_id
});

View File

@@ -0,0 +1,69 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.Permission;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
namespace Tnb.BasicData
{
/// <summary>
/// 标准工时
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class BasStandardTimeService : IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<BasStandardTime> _repository;
private readonly IUserManager _userManager;
private readonly IOrganizeService _organizeService;
public BasStandardTimeService(
ISqlSugarRepository<BasStandardTime> repository,
IOrganizeService organizeService,
IUserManager userManager
)
{
_repository = repository;
_organizeService = organizeService;
_userManager = userManager;
}
[HttpPost]
public async Task<dynamic?> SaveDate(BasStandardTime input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
if (input.enabled != null && input.enabled == 1)
{
await db.Updateable<BasStandardTime>()
.SetColumns(x => x.enabled == 0)
.Where(x => x.process_id == input.process_id)
.ExecuteCommandAsync();
}
if (input.id != null && !input.id.IsEmpty())
{
input.modify_id = _userManager.UserId;
input.modify_time = DateTime.Now;
await _repository.UpdateAsync(input);
}
else
{
input.id = SnowflakeIdHelper.NextId();
input.create_time = DateTime.Now;
input.create_id = _userManager.UserId;
await db.Insertable(input).ExecuteCommandAsync();
}
});
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "保存成功" : result.ErrorMessage);
}
}
}

View File

@@ -10,5 +10,8 @@ namespace Tnb.EquipMgr.Entities.Dto
public string? equip_id { get; set; }
public string? equip_id_id { get; set; }
public string? file_name { get; set; }
public string file_type { get; set; }
public string file_ext { get; set; }
}
}

View File

@@ -28,6 +28,16 @@ public partial class EqpEquipFile : BaseEntity<string>
/// 文件名
/// </summary>
public string file_name { get; set; } = string.Empty;
/// <summary>
/// 文件后缀
/// </summary>
public string file_ext { get; set; } = string.Empty;
/// <summary>
/// 文件类型
/// </summary>
public string file_type { get; set; } = string.Empty;
/// <summary>
/// 创建用户

View File

@@ -38,12 +38,12 @@ namespace Tnb.EquipMgr
}
[HttpPost]
public async Task<string> Upload([FromForm] string equip_id, [FromForm] ChunkModel input)
public async Task<string> Upload([FromForm] string equip_id,[FromForm] string file_type, [FromForm] ChunkModel input)
{
string msg;
try
{
dynamic attachment = await _fileService.Uploader("annexpic", input);
FileControlsModel attachment = await _fileService.Uploader("annexpic", input);
EqpEquipFile eqpEquipFile = new()
{
@@ -52,6 +52,8 @@ namespace Tnb.EquipMgr
create_id = _userManager.UserId,
create_time = DateTime.Now,
attachment = JsonConvert.SerializeObject(attachment),
file_ext = attachment.fileExtension,
file_type = file_type,
org_id = _userManager.GetUserInfo().Result.organizeId,
};
@@ -82,6 +84,7 @@ namespace Tnb.EquipMgr
.LeftJoin<EqpEquipment>((a, b, c, d) => a.equip_id == d.id)
.Where((a, b, c, d) => a.equip_id == input.equip_id)
.WhereIF(queryJson != null && queryJson.ContainsKey("file_name"), (a, b, c, d) => a.file_name.Contains(queryJson!["file_name"]))
.WhereIF(queryJson != null && queryJson.ContainsKey("file_type"), (a, b, c, d) => a.file_type==queryJson!["file_type"])
.Select((a, b, c, d) => new EquipFileQueryOutput
{
id = a.id,
@@ -91,6 +94,8 @@ namespace Tnb.EquipMgr
create_time = a.create_time == null ? null : a.create_time.Value.ToString("yyyy-MM-dd"),
equip_id = d.name,
equip_id_id = a.equip_id,
file_ext = a.file_ext,
file_type = a.file_type,
file_name = a.file_name,
}).ToPagedListAsync(input.currentPage, input.pageSize);

View File

@@ -28,5 +28,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
public string material_code { get; set; }
public string category_id { get; set; }
public decimal? num { get; set; }
/// <summary>
/// 比列分子
/// </summary>
public int molecule { get; set; }
/// <summary>
/// 比列分母
/// </summary>
public int denominator { get; set; }
}
}

View File

@@ -165,6 +165,16 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
public string warehouse_name { get; set; }
/// <summary>
/// 入库库位id
/// </summary>
public string? as_location_id { get; set; }
/// <summary>
/// 入库库位编号
/// </summary>
public string? as_location_code { get; set; }
}
}

View File

@@ -17,6 +17,10 @@
///<br/> Compled(任务完成)
/// </summary>
public string Behavior { get; set; }
/// <summary>
/// 暂停原因
/// </summary>
public String PauseReeson { get; set; }
}
}

View File

@@ -202,5 +202,9 @@ public partial class PrdMoTask : BaseEntity<string>
/// 批号
/// </summary>
public string? batch { get; set; }
/// <summary>
/// 暂停原因
/// </summary>
public string? pause_reason { get; set; }
}

View File

@@ -558,6 +558,7 @@ namespace Tnb.ProductionMgr
ISqlSugarClient db = _repository.AsSugarClient();
// string location_code = "ZCR01";//todo <20>̹ܼ<CCB9><DCBC><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>λ֮<CEBB><D6AE><EFBFBD><EFBFBD>
//todo <20><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD>
string warehouse_id = "2";
PrdInstockH? prdInstockH = null;

View File

@@ -261,7 +261,12 @@ namespace Tnb.ProductionMgr
{
if (!await db.Queryable<BasEbomH>().AnyAsync(x => x.material_id == item.material_id && x.version == item.ebom_version))
{
throw Oops.Bah($"系统中无法找到{item.ebom_version}版本");
throw Oops.Bah($"系统中无法找到物料清单{item.ebom_version}版本");
}
if (!await db.Queryable<BasMbom>().LeftJoin<BasEbomH>((a, b) => a.ebom_id == b.id).Where((a, b) => a.material_id == item.material_id && b.version == item.ebom_version).AnyAsync())
{
throw Oops.Bah($"系统中无法找到物料清单对应的生产bom{item.ebom_version}版本");
}
}
@@ -752,7 +757,8 @@ namespace Tnb.ProductionMgr
foreach (BasEbomD item in basEbomDs)
{
decimal? num1 = beforeReportNum / basEbomH.quantity * item.quantity;
// decimal? num1 = beforeReportNum / basEbomH.quantity * item.quantity;
decimal? num1 = beforeReportNum / basEbomH.quantity * (item.molecule/item.denominator);
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
.LeftJoin<PrdFeedingH>((a, b) => a.feeding_id == b.id)
.Where((a, b) => a.material_id == item.material_id && b.mo_task_id == mo_task_id)
@@ -768,7 +774,8 @@ namespace Tnb.ProductionMgr
}
else
{
decimal? num2 = prdReport.reported_qty / basEbomH.quantity * item.quantity;
// decimal? num2 = prdReport.reported_qty / basEbomH.quantity * item.quantity;
decimal? num2 = prdReport.reported_qty / basEbomH.quantity * (item.molecule/item.denominator);
if (sum2 <= num2)
{
prdFeedingIds.Add(item.id);
@@ -813,7 +820,8 @@ namespace Tnb.ProductionMgr
break;
}
decimal? num1 = beforeReportNum / Convert.ToDecimal(basMbomOutput.num) * item.num;
// decimal? num1 = beforeReportNum / Convert.ToDecimal(basMbomOutput.num) * item.num;
decimal? num1 = beforeReportNum / (basMbomOutput.molecule/basMbomOutput.denominator) * (item.molecule/item.denominator);
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
.LeftJoin<PrdFeedingH>((a, b) => a.feeding_id == b.id)
.Where((a, b) => a.material_id == item.material_id && b.mo_task_id == mo_task_id)
@@ -851,7 +859,8 @@ namespace Tnb.ProductionMgr
}
else
{
decimal? num2 = lastPrdReport.reported_qty / Convert.ToDecimal(basMbomOutput.num) * item.num;
// decimal? num2 = lastPrdReport.reported_qty / Convert.ToDecimal(basMbomOutput.num) * item.num;
decimal? num2 = lastPrdReport.reported_qty / (basMbomOutput.molecule/basMbomOutput.denominator) * (item.molecule/item.denominator);
if (sum2 <= num2)
{
lastPrdReportIds.Add(lastPrdReport.id);
@@ -879,7 +888,8 @@ namespace Tnb.ProductionMgr
}
else
{
decimal? num2 = prdReport.reported_qty / Convert.ToDecimal(basMbomOutput.num) * item.num;
// decimal? num2 = prdReport.reported_qty / Convert.ToDecimal(basMbomOutput.num) * item.num;
decimal? num2 = prdReport.reported_qty / (basMbomOutput.molecule/basMbomOutput.denominator) * (item.molecule/item.denominator);
if (sum2 <= num2)
{
prdFeedingIds.Add(item.id);
@@ -1083,7 +1093,8 @@ namespace Tnb.ProductionMgr
decimal residueNeed = 0;
foreach (PrdReport prdReport in prdReports)
{
decimal needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * basEbomD.quantity;
// decimal needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * basEbomD.quantity;
decimal needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * (basEbomD.molecule/basEbomD.denominator);
if (beforeIn - needNum >= 0)
{
beforeIn -= needNum;
@@ -1191,15 +1202,16 @@ namespace Tnb.ProductionMgr
BasMbomOutput output = outputList.FirstOrDefault(x => x.mbom_process_id == mbomProcesssIds[i] && x.material_id == tempMaterialId);
List<string> inputMaterialIds = inputs.Select(x => x.material_id).ToList();
List<BasMbomOutput> lastOutputs = outputList.Where(x => x.mbom_process_id == mbomProcesssIds[i - 1]).ToList();
decimal? inputNum = inputs.FirstOrDefault(x => inputMaterialIds.Contains(x.material_id))?.num;
if (inputNum == null)
// decimal? inputNum = inputs.FirstOrDefault(x => inputMaterialIds.Contains(x.material_id))?.num;
BasMbomInput? basMbomInput = inputs.FirstOrDefault(x => inputMaterialIds.Contains(x.material_id));
if (basMbomInput == null)
{
throw new Exception("生产bom投入产出物料配置错误");
}
else
{
tempMaterialId = inputs.FirstOrDefault(x => inputMaterialIds.Contains(x.material_id))?.material_id;
needNum = needNum / Convert.ToDecimal(output.num) * inputNum;
needNum = needNum / (output.molecule/output.denominator) * (basMbomInput.molecule/basMbomInput.denominator);
}
}

View File

@@ -944,6 +944,8 @@ namespace Tnb.ProductionMgr
process_id = b.process_id,
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
num = e.num,
molecule = e.molecule,
denominator = e.denominator,
ordinal = d.ordinal,
mbom_process_id = b.id,
})
@@ -1149,6 +1151,8 @@ namespace Tnb.ProductionMgr
{
throw Oops.Bah("状态错误无法暂停");
}
item.pause_reason = input.PauseReeson;
break;
case PrdTaskBehavior.Compled:
if (item.mo_task_status == status)
@@ -2715,7 +2719,9 @@ namespace Tnb.ProductionMgr
material_id = x.material_id,
material_code = y.code,
category_id = y.category_id,
num = x.num
num = x.num,
molecule = x.molecule,
denominator = x.denominator,
})
}).ToListAsync();

View File

@@ -417,7 +417,7 @@ namespace Tnb.ProductionMgr
.LeftJoin<EqpEquipment>((a, b, c, d, e, f) => a.eqp_id == f.id)
.LeftJoin<ToolMolds>((a, b, c, d, e, f, g) => a.mold_id == g.id)
.LeftJoin<PerProcessStandardsH>((a, b, c, d, e, f, g, h) => a.material_id == h.output_material_id && a.eqp_id == h.equip_id && a.mold_id == h.molds_id && h.enabled == 1)
.LeftJoin<BasStandardTime>((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1)
.LeftJoin<BasStandardTime>((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1 && a.schedule_type==1)
.LeftJoin<PrdMo>((a, b, c, d, e, f, g, h, i, j) => a.mo_id == j.id)
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg")
.LeftJoin<EqpDaq>((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_point == "注塑空满箱请求")
@@ -469,11 +469,32 @@ namespace Tnb.ProductionMgr
deputy_num = k.number_of_auxiliary_unit,
third_equip_code = l.equip_code,
weight_name = l.label_name,
category_id = b.category_id
category_id = b.category_id,
as_location_id = f.as_location_id
})
.MergeTable()
.OrderBy($"{input.sidx} {input.sort}")
.ToPagedListAsync(input.currentPage, input.pageSize);
if (!result.list.IsEmpty())
{
foreach (var item in result.list)
{
if (item.as_location_id!=null && !item.as_location_id.IsEmpty())
{
BasLocation basLocation = await _db.Queryable<BasLocation>().SingleAsync(x => x.id == item.as_location_id);
item.as_location_code = basLocation.location_code;
}
if (item.schedule_type == 2)
{
PerProcessStandardsH processStandardsH = await _db.Queryable<PerProcessStandardsH>()
.Where(x => x.equip_id == item.equip_id && x.molds_id == item.mold_id &&
x.output_material_id == item.material_id && x.enabled == 1)
.OrderByDescending(x => x.create_time).FirstAsync();
item.standard_time = processStandardsH?.moulding_cycle?.ToString();
}
}
}
return PageResult<PADPackageTaskPageOutput>.SqlSugarPageResult(result);

View File

@@ -0,0 +1,197 @@
using Aop.Api.Domain;
using JNPF;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Interfaces.Permission;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using SqlSugar.Extensions;
using Tnb.BasicData.Entities;
using Tnb.Common.Redis;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Result = Tnb.WarehouseMgr.Entities.Dto.Outputs.Result;
using Tnb.BasicData;
using Tnb.WarehouseMgr;
namespace Tnb.ProductionMgr
{
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class TimeWorkService : IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<BasMaterial> _repository;
private readonly IOrganizeService _organizeService;
private readonly IBillRullService _billRullService;
private readonly RedisData _redisData;
private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService;
public TimeWorkService(
RedisData redisData,
ISqlSugarRepository<BasMaterial> repository,
IBillRullService billRullService,
IOrganizeService organizeService,
IWmsEmptyOutstockService wmsEmptyOutstockService
)
{
_redisData = redisData;
_repository = repository;
_organizeService = organizeService;
_billRullService = billRullService;
_wmsEmptyOutstockService = wmsEmptyOutstockService;
}
[HttpGet]
[AllowAnonymous]
public async Task<dynamic> test()
{
var db = _repository.AsSugarClient();
await db.Ado.BeginTranAsync();
BasUnit basUnit = new BasUnit();
basUnit.id = SnowflakeIdHelper.NextId();
basUnit.unit_name = "aaa";
basUnit.unit_code = "bbb";
await db.Insertable(basUnit).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
await db.Ado.BeginTranAsync();
BasUnit basUnit2 = new BasUnit();
basUnit2.id = SnowflakeIdHelper.NextId();
basUnit2.unit_name = "ccc";
basUnit2.unit_code = "ddd";
await db.Insertable(basUnit2).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
return Task.CompletedTask;
}
/// <summary>
/// 注塑空载具出库
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<dynamic> EmptyCarryOutStk()
{
bool? cs01 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS01");
bool? cs03 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS03");
bool cs01Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS01_flag");
bool cs03Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS03_flag");
if (cs01==true && !cs01Flag)
{
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-left");
}
if (cs03==true && !cs03Flag)
{
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-right");
}
return Task.CompletedTask;
}
[HttpGet]
[AllowAnonymous]
public async Task<dynamic> EmptyCarryOutStkLeft()
{
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "SSX-021-001";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
input.qty = 1;
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】左输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
if (result.code == HttpStatusCode.OK)
{
Log.Information("【EmptyCarryOutStk】左输送线空箱入呼叫成功");
//_redisData.Set("YTCS_CallCtuEmptyIn_CS01_flag", true, TimeSpan.FromMinutes(20));
}
return Task.CompletedTask;
}
[HttpGet]
[AllowAnonymous]
public async Task<dynamic> EmptyCarryOutStkRight()
{
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "SSX-021-003";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
input.qty = 1;
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】右输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
if (result.code == HttpStatusCode.OK)
{
Log.Information("【EmptyCarryOutStk】右输送线空箱入呼叫成功");
//_redisData.Set("YTCS_CallCtuEmptyIn_CS03_flag", true, TimeSpan.FromMinutes(20));
}
return Task.CompletedTask;
}
[HttpGet]
[AllowAnonymous]
public async Task<dynamic> FixedPointDelivery()
{
bool? value = await _redisData.TryGetValueByKeyField<bool?>("hxjA", "DB100.132.0");
bool valueFlag = _redisData.Get<bool>("hxjA_DB100.132.0_flag");
if (value==true && !valueFlag)
{
bool? cs01 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS01");
bool? cs03 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS03");
string startLocationCode = cs01==false ? "SSX-021-001" : cs03==false ? "SSX-021-003" : "";
if (startLocationCode.IsEmpty())
{
return Task.CompletedTask;
}
var db = _repository.AsSugarClient();
Dictionary<String, Object> postData = new Dictionary<string, object>();
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
};
BasFactoryConfig config = await db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
string sendResult = HttpUtils.RequestPost($"{config.value}/api/visualdev/OnlineDev/{ModuleConsts.MODULE_WMSDELIVERYPDA_ID}", JsonConvert.SerializeObject(postData), header);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if(authResponse.code == 200 && authResponse.data.ObjToBool())
{
Log.Information("【FixedPointDelivery】注塑定点配送成功");
//_redisData.Set("DB100.132.0_flag", true, TimeSpan.FromMinutes(20));
}
else
{
Log.Information(sendResult);
}
}
return Task.CompletedTask;
}
}
}

View File

@@ -322,5 +322,9 @@
/// 一楼中储仓出库工位
/// </summary>
public const string ZZCSSX111012 = "32609251845653";
/// <summary>
/// 料箱id
/// </summary>
public const string LIAOXIANGID = "26037262680357";
}
}

View File

@@ -5,11 +5,13 @@ using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.EventBus;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -19,6 +21,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
using Result = Tnb.WarehouseMgr.Entities.Dto.Outputs.Result;
namespace Tnb.WarehouseMgr
@@ -86,6 +89,7 @@ namespace Tnb.WarehouseMgr
// && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString())
// .ToListAsync();
// 判断最终目标库位是否可以放置当前载具
WmsEmptyOutstockH wmsEmptyOutstockH = null;
if (carrys?.Count > 0)
{
WmsCarryH curCarry = carrys[^carrys.Count];
@@ -95,8 +99,12 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("该载具无法放置到目标库位", 500);
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
// VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
// await _runService.Create(templateEntity, input);
wmsEmptyOutstockH = JsonConvert.DeserializeObject<WmsEmptyOutstockH>(JsonConvert.SerializeObject(input.data));
wmsEmptyOutstockH.id = SnowflakeIdHelper.NextId();
await _db.Insertable(wmsEmptyOutstockH).ExecuteCommandAsync();
}
@@ -144,7 +152,7 @@ namespace Tnb.WarehouseMgr
WmsPretaskH preTask = new()
{
org_id = _userManager.User.OrganizeId,
org_id = wmsEmptyOutstockH.org_id,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
@@ -163,9 +171,10 @@ namespace Tnb.WarehouseMgr
carry_code = carrys![i].carry_code,
area_id = sPoint?.area_id!,
area_code = it.Key,
require_id = input.data["ReturnIdentity"].ToString(),
// require_id = input.data["ReturnIdentity"].ToString(),
require_id = wmsEmptyOutstockH.id,
require_code = input.data[nameof(preTask.bill_code)]?.ToString()!,
create_id = _userManager.UserId,
create_id = wmsEmptyOutstockH.create_id,
create_time = DateTime.Now
};
@@ -184,7 +193,7 @@ namespace Tnb.WarehouseMgr
{
GenPreTaskUpInput preTaskUpInput = new()
{
RquireId = input.data["ReturnIdentity"].ToString()!,
RquireId = wmsEmptyOutstockH.id!,
CarryId = carrys![i].id,
CarryStartLocationId = points!.FirstOrDefault()!.location_id!,
CarryStartLocationCode = points!.FirstOrDefault()!.location_code!,
@@ -201,7 +210,7 @@ namespace Tnb.WarehouseMgr
status = WmsWareHouseConst.BILLSTATUS_ON_ID,
carry_id = carrys[i].id,
carry_code = carrys[i].carry_code,
create_id = _userManager.UserId,
create_id = wmsEmptyOutstockH.create_id,
create_time = DateTime.Now
};
_ = await _db.Insertable(wmsEmptyOutstockD)
@@ -300,6 +309,7 @@ namespace Tnb.WarehouseMgr
[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
[nameof(WmsEmptyOutstockH.qty)] = input.qty,
[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
["warehouse_id"] = input.warehouse_id,
[nameof(WmsEmptyOutstockH.create_id)] = input.create_id,
[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now
};
@@ -312,10 +322,11 @@ namespace Tnb.WarehouseMgr
}
catch (Exception ex)
{
Log.Error(ex.Message,ex);
await _db.Ado.RollbackTranAsync();
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return ToApiResult();
return new Result();
}
}
}

View File

@@ -8,6 +8,7 @@ using JNPF;
using JNPF.Common.Cache;
using JNPF.DependencyInjection;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace Tnb.Common.Redis
{
@@ -243,5 +244,25 @@ namespace Tnb.Common.Redis
{
return _instance.HSetAsync(key, field, value);
}
public async Task<T> TryGetValueByKeyField<T>(string key, string field)
{
if (await _instance.HExistsAsync(key, field))
{
string data = await GetHash(key, field);
Dictionary<String, String> json = JsonConvert.DeserializeObject<Dictionary<String, String>>(data);
Type type = typeof(T);
if (!type.IsValueType || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
return (T)Convert.ChangeType(json["Value"],type.GetGenericArguments()[0]);
}
else
{
return (T)Convert.ChangeType(json["Value"],type);
}
// return ;
}
return default(T);
}
}
}