diff --git a/BasicData/Tnb.BasicData.Entities/Consts/FactoryConfigConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/FactoryConfigConst.cs index 1b16c47f..8d256f63 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/FactoryConfigConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/FactoryConfigConst.cs @@ -14,5 +14,10 @@ namespace Tnb.BasicData /// 报工允许超过工单计划数百分比 例:填写10就是10% /// public const string IS_SURPASS_PERCENTAGE = "is_surpass_percentage"; + + /// + /// 域名 + /// + public const string DOMAIN = "domain"; } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs index fc446c5c..637fec3b 100644 --- a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs @@ -78,6 +78,15 @@ namespace Tnb.BasicData.Entities.Dto /// Nullable:True /// public string? version { get; set; } + + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs index f2f1d541..8b149423 100644 --- a/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs @@ -63,5 +63,14 @@ /// 生产bom工序id /// public string? mbom_process_id { get; set; } + + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } } } diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs index ed7390e0..eacd115d 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs @@ -73,5 +73,13 @@ public partial class BasEbomD : BaseEntity /// 工艺路线名称 /// public string? route_name { get; set; } + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } } diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomInput.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomInput.cs index 6769d48a..a710a2f2 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomInput.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomInput.cs @@ -48,5 +48,14 @@ public partial class BasMbomInput : BaseEntity /// 单位id /// public string? unit_id { get; set; } + + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } } diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs index 8ade2a09..b238218b 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs @@ -48,5 +48,14 @@ public partial class BasMbomOutput : BaseEntity /// 单位id /// public string? unit_id { get; set; } + + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } } diff --git a/BasicData/Tnb.BasicData/BasEbomService.cs b/BasicData/Tnb.BasicData/BasEbomService.cs index 9cedf8a3..a84a6cfc 100644 --- a/BasicData/Tnb.BasicData/BasEbomService.cs +++ b/BasicData/Tnb.BasicData/BasEbomService.cs @@ -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, diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index cee2b86b..4d2a2482 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -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 }); diff --git a/BasicData/Tnb.BasicData/BasStandardTimeService.cs b/BasicData/Tnb.BasicData/BasStandardTimeService.cs new file mode 100644 index 00000000..d366aca1 --- /dev/null +++ b/BasicData/Tnb.BasicData/BasStandardTimeService.cs @@ -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 +{ + /// + /// 标准工时 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class BasStandardTimeService : IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + private readonly IOrganizeService _organizeService; + + public BasStandardTimeService( + ISqlSugarRepository repository, + IOrganizeService organizeService, + IUserManager userManager + ) + { + _repository = repository; + _organizeService = organizeService; + _userManager = userManager; + } + + [HttpPost] + public async Task SaveDate(BasStandardTime input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + if (input.enabled != null && input.enabled == 1) + { + await db.Updateable() + .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); + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs index 01f09767..b5f59b08 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs @@ -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; } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs index b2919f9b..746aa8c5 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs @@ -28,6 +28,16 @@ public partial class EqpEquipFile : BaseEntity /// 文件名 /// public string file_name { get; set; } = string.Empty; + + /// + /// 文件后缀 + /// + public string file_ext { get; set; } = string.Empty; + + /// + /// 文件类型 + /// + public string file_type { get; set; } = string.Empty; /// /// 创建用户 diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs index 61d56003..b035c051 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs @@ -38,12 +38,12 @@ namespace Tnb.EquipMgr } [HttpPost] - public async Task Upload([FromForm] string equip_id, [FromForm] ChunkModel input) + public async Task 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((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); diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs index 3c583966..44cc660a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs @@ -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; } + /// + /// 比列分子 + /// + public int molecule { get; set; } + /// + /// 比列分母 + /// + public int denominator { get; set; } + } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs index fe96dc58..26bb1497 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PADPackageTaskPageOutput.cs @@ -165,6 +165,16 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string warehouse_name { get; set; } + /// + /// 入库库位id + /// + public string? as_location_id { get; set; } + + /// + /// 入库库位编号 + /// + public string? as_location_code { get; set; } + } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskReleaseUpInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskReleaseUpInput.cs index 7c02ae35..68867e76 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskReleaseUpInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskReleaseUpInput.cs @@ -17,6 +17,10 @@ ///
Compled(任务完成) ///
public string Behavior { get; set; } + /// + /// 暂停原因 + /// + public String PauseReeson { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index 905d73a0..56af072f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -202,5 +202,9 @@ public partial class PrdMoTask : BaseEntity /// 批号 /// public string? batch { get; set; } + /// + /// 暂停原因 + /// + public string? pause_reason { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 80ace7e1..f266d8f2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -558,6 +558,7 @@ namespace Tnb.ProductionMgr ISqlSugarClient db = _repository.AsSugarClient(); // string location_code = "ZCR01";//todo ̹ܼĿλ֮ + //todo ֿȷٸ string warehouse_id = "2"; PrdInstockH? prdInstockH = null; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 15396871..484b2e6b 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -261,7 +261,12 @@ namespace Tnb.ProductionMgr { if (!await db.Queryable().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().LeftJoin((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 prdFeedingDs = await _db.Queryable() .LeftJoin((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 prdFeedingDs = await _db.Queryable() .LeftJoin((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 inputMaterialIds = inputs.Select(x => x.material_id).ToList(); List 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); } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 2a8c249d..dd5559b0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -944,6 +944,8 @@ namespace Tnb.ProductionMgr process_id = b.process_id, material_id = SqlFunc.Subqueryable().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(); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 8f442b57..1fbee1b4 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -417,7 +417,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d, e, f) => a.eqp_id == f.id) .LeftJoin((a, b, c, d, e, f, g) => a.mold_id == g.id) .LeftJoin((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((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1) + .LeftJoin((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1 && a.schedule_type==1) .LeftJoin((a, b, c, d, e, f, g, h, i, j) => a.mo_id == j.id) .LeftJoin((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg") .LeftJoin((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().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() + .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.SqlSugarPageResult(result); diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs new file mode 100644 index 00000000..71833489 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -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 _repository; + private readonly IOrganizeService _organizeService; + private readonly IBillRullService _billRullService; + private readonly RedisData _redisData; + private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService; + + public TimeWorkService( + RedisData redisData, + ISqlSugarRepository repository, + IBillRullService billRullService, + IOrganizeService organizeService, + IWmsEmptyOutstockService wmsEmptyOutstockService + ) + { + _redisData = redisData; + _repository = repository; + _organizeService = organizeService; + _billRullService = billRullService; + _wmsEmptyOutstockService = wmsEmptyOutstockService; + } + + [HttpGet] + [AllowAnonymous] + public async Task 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; + } + + /// + /// 注塑空载具出库 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task EmptyCarryOutStk() + { + bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS01"); + bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS03"); + bool cs01Flag = _redisData.Get("YTCS_CallCtuEmptyIn_CS01_flag"); + bool cs03Flag = _redisData.Get("YTCS_CallCtuEmptyIn_CS03_flag"); + if (cs01==true && !cs01Flag) + { + BasFactoryConfig config = await _repository.AsSugarClient().Queryable().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().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 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 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 FixedPointDelivery() + { + bool? value = await _redisData.TryGetValueByKeyField("hxjA", "DB100.132.0"); + bool valueFlag = _redisData.Get("hxjA_DB100.132.0_flag"); + if (value==true && !valueFlag) + { + bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS01"); + bool? cs03 = await _redisData.TryGetValueByKeyField("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 postData = new Dictionary(); + + + Dictionary header = new() + { + ["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : "" + }; + BasFactoryConfig config = await db.Queryable().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(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; + } + + } +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 3550467c..7d51555e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -322,5 +322,9 @@ /// 一楼中储仓出库工位 /// public const string ZZCSSX111012 = "32609251845653"; + /// + /// 料箱id + /// + public const string LIAOXIANGID = "26037262680357"; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index a2754ae6..20344846 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -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(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(); } } } diff --git a/common/Tnb.Common/Redis/RedisData.cs b/common/Tnb.Common/Redis/RedisData.cs index 3c296f5c..8b06a2b8 100644 --- a/common/Tnb.Common/Redis/RedisData.cs +++ b/common/Tnb.Common/Redis/RedisData.cs @@ -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 TryGetValueByKeyField(string key, string field) + { + if (await _instance.HExistsAsync(key, field)) + { + string data = await GetHash(key, field); + Dictionary json = JsonConvert.DeserializeObject>(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); + } } } \ No newline at end of file