From aad4888c14dadaa24d4810e1e9e4333ff7ca0689 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 10:08:32 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E4=B8=80=E8=88=AC=E5=87=BA=E5=BA=93?=
=?UTF-8?q?=E7=94=B3=E8=AF=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Consts/DictConst.cs | 10 ++
.../Dto/PrdManage/GeneralOutstockInput.cs | 29 +++++
.../Entity/PrdOutstockD.cs | 2 +-
.../IPrdOutstockService.cs | 8 +-
.../Tnb.ProductionMgr/PrdOutstockService.cs | 122 +++++++++++++++++-
5 files changed, 168 insertions(+), 3 deletions(-)
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GeneralOutstockInput.cs
diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
index da84b4d4..69611399 100644
--- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
+++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
@@ -169,6 +169,16 @@ public static class DictConst
///
public const string CHANCHENGPINRUKUDAN = "40";
+ ///
+ /// 生产领料单
+ ///
+ public const string SHENGCHANLINGLIAO = "23";
+
+ ///
+ /// 生产补料单
+ ///
+ public const string SHENGCHANBULIAO = "24";
+
#endregion
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GeneralOutstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GeneralOutstockInput.cs
new file mode 100644
index 00000000..79368c6f
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GeneralOutstockInput.cs
@@ -0,0 +1,29 @@
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class GeneralOutstockInput
+ {
+ ///
+ /// 目标库位编号
+ ///
+ public string location_code { get; set; } = string.Empty;
+
+ /// 所属工位
+ ///
+ public string? workstation_id { get; set; }
+
+ ///
+ /// 任务单
+ ///
+ public string? mo_task_id { get; set; }
+
+ public List details { get; set; } = new List();
+ }
+
+ public class GeneralOutstockDInput
+ {
+ public string material_id { get; set; }
+ public string material_code { get; set; }
+ public string material_name { get; set; }
+ public decimal num { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs
index 960834c6..86c1328a 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs
@@ -32,7 +32,7 @@ public partial class PrdOutstockD : BaseEntity
///
/// 出库需求数量
///
- public string? pr_qty { get; set; }
+ public decimal? pr_qty { get; set; }
///
/// 来源单据id
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs
index 3d8bed0f..0a669e72 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs
@@ -1,3 +1,5 @@
+using Tnb.ProductionMgr.Entities.Dto;
+
namespace Tnb.ProductionMgr.Interfaces
{
///
@@ -5,6 +7,10 @@ namespace Tnb.ProductionMgr.Interfaces
///
public interface IPrdOutstockService
{
-
+ ///
+ /// 一般出库申请
+ ///
+ ///
+ public Task GeneralOutstock(GeneralOutstockInput input);
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
index fef2d924..da415616 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
@@ -7,6 +7,9 @@ using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
using JNPF.Logging;
+using JNPF.Systems.Entitys.Permission;
+using JNPF.Systems.Entitys.System;
+using JNPF.Systems.Interfaces.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
@@ -14,10 +17,12 @@ using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+using Spire.Pdf.Exporting.XPS.Schema;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
@@ -37,10 +42,11 @@ namespace Tnb.ProductionMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IDictionaryDataService _dictionaryDataService;
+ private readonly IOrganizeService _organizeService;
private readonly IUserManager _userManager;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
- public PrdOutstockService(ISqlSugarRepository repository, IRunService runService, IUserManager userManager,IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
+ public PrdOutstockService(ISqlSugarRepository repository, IOrganizeService organizeService,IRunService runService, IUserManager userManager,IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -48,6 +54,7 @@ namespace Tnb.ProductionMgr
_dictionaryDataService = dictionaryDataService;
_repository = repository;
_userManager = userManager;
+ _organizeService = organizeService;
OverideFuncs.CreateAsync = Create;
}
@@ -114,5 +121,118 @@ namespace Tnb.ProductionMgr
}
}
+
+ public async Task GeneralOutstock(GeneralOutstockInput generalOutstockInput)
+ {
+ try
+ {
+ var db = _repository.AsSugarClient();
+ string warehouse_id = "26103348825381";//二楼缓存仓
+
+ MESCreateOutstockInput input = new MESCreateOutstockInput();
+ input.outstock = new MESWmsOutstockHInput();
+ input.outstockDs = new List();
+
+ PrdMoTask prdMoTask = await db.Queryable().SingleAsync(x=>x.id==generalOutstockInput.mo_task_id);
+ BasLocation location = await db.Queryable().Where(x=>x.location_code==generalOutstockInput.location_code).FirstAsync();
+ if (location == null) throw Oops.Bah("未找到库位");
+ string locationId = location.id;
+
+ input.outstock.bill_type = DictConst.SHENGCHANLINGLIAO;
+ // input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now;
+ input.outstock.bill_date = DateTime.Now;
+ input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId;
+ input.outstock.warehouse_id = warehouse_id;
+ input.outstock.create_id = _userManager.UserId;
+ input.outstock.location_code = location?.location_code ?? "";
+ OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(generalOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode);
+
+ List materialIds = generalOutstockInput.details.Select(x => x.material_id).ToList();
+ Dictionary unitIdDic = await db.Queryable()
+ .LeftJoin((a, b) => b.EnCode == DictConst.MeasurementUnit)
+ .LeftJoin((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode)
+ .Where((a,b,c)=>materialIds.Contains(a.id))
+ .Select((a, b, c) => new
+ {
+ key = a.id,
+ value = c.Id
+ })
+ .ToDictionaryAsync(x => x.key, x => x.value);
+
+ foreach (var item in generalOutstockInput.details)
+ {
+ input.outstockDs.Add(new MESWmsOutstockDInput()
+ {
+ material_id = item.material_id,
+ material_code = item.material_code,
+ pr_qty = item.num,
+ unit_id = unitIdDic[item.material_id].ToString()
+ });
+ }
+
+ string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
+ Dictionary header = new Dictionary()
+ {
+ ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
+ };
+ var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK,JsonConvert.SerializeObject(input),header);
+ Log.Information(sendResult);
+
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ PrdOutstockH prdOutstockH = new PrdOutstockH();
+ prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO;
+ prdOutstockH.warehouse_id = warehouse_id;
+ prdOutstockH.location_code = generalOutstockInput.location_code;
+ prdOutstockH.create_id = _userManager.UserId;
+ prdOutstockH.org_id = _userManager.GetUserInfo().Result.organizeId;
+ prdOutstockH.bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ prdOutstockH.workstation = generalOutstockInput.workstation_id;
+ prdOutstockH.workline = workline?.Id ?? "";
+
+ List prdOutstockDs = new List();
+ foreach (var item in generalOutstockInput.details)
+ {
+ prdOutstockDs.Add(new PrdOutstockD()
+ {
+ material_id = item.material_id,
+ material_code = item.material_code,
+ material_name = item.material_name,
+ pr_qty = item.num,
+ unit_id = unitIdDic[item.material_id].ToString(),
+ outstock_id = prdOutstockH.id,
+ source_id = prdMoTask.mo_task_code
+ });
+ }
+
+ DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
+ {
+ await _repository.InsertAsync(prdOutstockH);
+ if (prdOutstockDs.Count > 0)
+ {
+ await db.Insertable(prdOutstockDs).ExecuteCommandAsync();
+ }
+ });
+
+ if (!result.IsSuccess)
+ {
+ throw Oops.Bah(result.ErrorMessage);
+ }
+
+ }
+ return await Task.FromResult(true);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ Log.Error(e.Message);
+ throw Oops.Bah(e.Message);
+ }
+ }
}
}
\ No newline at end of file
From 8c8284a72d66c4a4cf3613d04f5ef52cad91a5f8 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 10:27:22 +0800
Subject: [PATCH 2/6] 1
---
ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
index da415616..cdd4c2b0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
@@ -148,6 +148,7 @@ namespace Tnb.ProductionMgr
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(generalOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode);
List materialIds = generalOutstockInput.details.Select(x => x.material_id).ToList();
+ List basMaterials = await db.Queryable().Where(x=>materialIds.Contains(x.id)).ToListAsync();
Dictionary unitIdDic = await db.Queryable()
.LeftJoin((a, b) => b.EnCode == DictConst.MeasurementUnit)
.LeftJoin((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode)
@@ -164,7 +165,7 @@ namespace Tnb.ProductionMgr
input.outstockDs.Add(new MESWmsOutstockDInput()
{
material_id = item.material_id,
- material_code = item.material_code,
+ material_code = basMaterials.First(x=>x.id==item.material_id).code,
pr_qty = item.num,
unit_id = unitIdDic[item.material_id].ToString()
});
@@ -201,8 +202,8 @@ namespace Tnb.ProductionMgr
prdOutstockDs.Add(new PrdOutstockD()
{
material_id = item.material_id,
- material_code = item.material_code,
- material_name = item.material_name,
+ material_code = basMaterials.First(x=>x.id==item.material_id).code,
+ material_name = basMaterials.First(x=>x.id==item.material_id).name,
pr_qty = item.num,
unit_id = unitIdDic[item.material_id].ToString(),
outstock_id = prdOutstockH.id,
From a055ac33ef6810f5f1ab94656121e06a20af17c0 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 15:30:31 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=B7=A5=E4=BD=8Did?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E8=BF=9B=E8=A1=8C=E4=B8=AD?=
=?UTF-8?q?=E7=9A=84=E4=BB=BB=E5=8A=A1=E5=8D=95=20=E7=94=9F=E4=BA=A7?=
=?UTF-8?q?=E6=8A=95=E6=96=99=E6=96=B0=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IPrdMoTaskService.cs | 9 +-
.../Tnb.ProductionMgr/PrdFeedingService.cs | 126 ++++++++++++++++++
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 21 ++-
3 files changed, 154 insertions(+), 2 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
index 29f0b0aa..ba1668ad 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
@@ -25,6 +25,13 @@ namespace Tnb.ProductionMgr.Interfaces
///
///
Task GetMaterialPreparationPlan();
-
+
+ ///
+ /// 根据工位获取进行中的任务单信息
+ ///
+ ///
+ ///
+ Task GetPrdMoTaskInfoByStationId(Dictionary dic);
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 183953d8..61872a53 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -36,6 +36,7 @@ namespace Tnb.ProductionMgr
{
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
+ private readonly IPrdMoTaskService _prdMoTaskService;
private readonly IBillRullService _billRullService;
// private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
@@ -44,12 +45,14 @@ namespace Tnb.ProductionMgr
public PrdFeedingService(
ISqlSugarRepository repository,
IBillRullService billRullService,
+ IPrdMoTaskService prdMoTaskService,
// WmsSignForDeliveryService wmsSignForDeliveryService,
IUserManager userManager
)
{
_repository = repository;
_userManager = userManager;
+ _prdMoTaskService = prdMoTaskService;
// _wmsSignForDeliveryService = _wmsSignForDeliveryService;
_billRullService = billRullService;
}
@@ -331,6 +334,129 @@ namespace Tnb.ProductionMgr
if(!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
}
+
+
+ ///
+ /// 生产投料
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task Feeding(MaterialReceiptNewInput input)
+ {
+ var db = _repository.AsSugarClient();
+ var moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary()
+ {
+ {"station_id",input.station_id}
+ });
+
+ if (moTask == null) throw Oops.Bah("找不到任务单");
+ PrdFeedingH prdFeedingH = null;
+ List list = new List();
+ DbResult result2 = new DbResult();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ var parentMoTask = await db.Queryable().FirstAsync(x => x.id == moTask.parent_id);
+ string worklineId = moTask.workline_id;
+ if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
+ {
+ worklineId = parentMoTask.workline_id;
+ }
+ var carry = await db.Queryable().SingleAsync(x => x.carry_code == input.carry_code);
+ var workline = await db.Queryable().SingleAsync(x => x.Id == worklineId);
+ var workshop = await db.Queryable().SingleAsync(x=>x.Id==workline.ParentId);
+ var inputMaterials = await db.Queryable()
+ .Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
+ .Select(x=>x.material_id)
+ .ToListAsync();
+
+
+ string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
+ prdFeedingH = new PrdFeedingH()
+ {
+ code = code,
+ station_id = input.station_id,
+ mo_task_id = moTask.id,
+ process_id = moTask.process_id,
+ equip_id = input.equip_id,
+ workshop_id = workshop?.Id,
+ carry_id = carry.id,
+ workline_id = moTask.workline_id,
+ carry_code = input.carry_code,
+ // remark = input.remark,
+ mbom_process_id = moTask.mbom_process_id,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId
+ };
+
+ if (input.details != null && input.details.Count > 0)
+ {
+ foreach (var item in input.details)
+ {
+ if(!inputMaterials.Contains(item["material_id"]))
+ throw new Exception("该物料不是生产bom投入物料,不能签收");
+
+ var detail = await db.Queryable()
+ .Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
+ decimal num = Convert.ToDecimal(item["num"]);
+ list.Add(new PrdFeedingD
+ {
+ feeding_id = prdFeedingH.id,
+ material_receipt_detail_id = detail?.id,
+ material_id = item["material_id"],
+ num = num,
+ batch = item["batch"],
+ unit_id = item["unit_id"],
+ carry_id = carry.id,
+ status = "0",
+ use_num = 0,
+ });
+
+ if (detail != null)
+ {
+ if(detail.feeding_num + num > detail.num)
+ {
+ throw new Exception("投料数量不能大于签收数量");
+ }else if (detail.feeding_num + num == detail.num)
+ {
+ await db.Updateable()
+ .SetColumns(x => x.feeding_num == x.feeding_num + num)
+ .SetColumns(x => x.is_all_feeding == 1)
+ .Where(x => x.id == detail.id)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ await db.Updateable()
+ .SetColumns(x => x.feeding_num == x.feeding_num + num)
+ .Where(x => x.id == detail.id)
+ .ExecuteCommandAsync();
+ }
+ }
+ else
+ {
+ throw new Exception("没有签收单,无法投料");
+ }
+ }
+ }
+ else
+ {
+ throw new Exception("没有签收物料");
+ }
+
+
+ await db.Insertable(prdFeedingH).ExecuteCommandAsync();
+ await db.Insertable(list).ExecuteCommandAsync();
+
+ });
+
+
+ if(!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
+ return result.IsSuccess ? "签收成功" : result.ErrorMessage;
+ }
[HttpPost]
public async Task GetFeedingRecordTree()
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 7f2dea96..0a34213d 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -1447,6 +1447,7 @@ namespace Tnb.ProductionMgr
var row = -1;
var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id);
+ var equip = await db.Queryable().SingleAsync(x=>x.id==prdMoTask.eqp_id);
var prdMo = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id);
var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
@@ -1724,6 +1725,11 @@ namespace Tnb.ProductionMgr
// }
// }
+ if (equip.tube == "1")
+ {
+
+ }
+
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
@@ -2627,6 +2633,7 @@ namespace Tnb.ProductionMgr
rate_num = SqlFunc.Subqueryable().Where(o => o.id == a.bom_id)
.OrderByDesc(o => o.create_time).Select(o => o.num),
parent_id = b.parent_id,
+ workstation_id = b.workstation_id,
material_id = b.material_id,
material_code = c.code,
children = SqlFunc.Subqueryable()
@@ -2643,7 +2650,7 @@ namespace Tnb.ProductionMgr
var prdMoTaskList = await _db.Queryable()
.LeftJoin((a, b) => a.material_id == b.id)
- .Where(a => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id) && a.estimated_start_date.Value.ToString("yyyy-MM-dd") == now)
+ .Where(a => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id) && a.estimated_start_date.Value.ToString("yyyy-MM-dd") == now && (a.mo_task_status==DictConst.MoStatusPauseCode || a.mo_task_status==DictConst.ToBeScheduledEncode || a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode))
.Select((a,b)=>new MaterialPreparationPlanOutput()
{
mo_task_id = a.id,
@@ -2672,6 +2679,18 @@ namespace Tnb.ProductionMgr
return prdMoTaskList;
}
+ ///
+ /// 根据工位获取进行中的任务单信息
+ ///
+ ///
+ ///
+ public async Task GetPrdMoTaskInfoByStationId(Dictionary dic)
+ {
+ string station_id = dic.ContainsKey("station_id") ? dic["station_id"] : "";
+ if (string.IsNullOrEmpty(station_id)) throw Oops.Bah("工位错误");
+
+ return await _db.Queryable().Where(x => x.workstation_id == station_id && x.parent_id!=null && x.mo_task_status==DictConst.InProgressEnCode).FirstAsync();
+ }
}
From bab70ddd518f684fac5a1185833931d888bc0ed5 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 15:41:25 +0800
Subject: [PATCH 4/6] 1
---
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 0a34213d..5d9d1af0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -2619,6 +2619,7 @@ namespace Tnb.ProductionMgr
/// 获取备料计划
///
///
+ [HttpPost]
public async Task GetMaterialPreparationPlan()
{
string now = DateTime.Now.ToString("yyyy-MM-dd");
@@ -2684,6 +2685,7 @@ namespace Tnb.ProductionMgr
///
///
///
+ [HttpPost]
public async Task GetPrdMoTaskInfoByStationId(Dictionary dic)
{
string station_id = dic.ContainsKey("station_id") ? dic["station_id"] : "";
From 9ee80fe00f1a7c13d4a3810234b64fbbb6506012 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 16:20:10 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E7=9F=AD=E7=AE=A1=E6=8C=A4=E5=87=BA?=
=?UTF-8?q?=E5=85=A5=E5=BA=93=E7=94=B3=E8=AF=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IPrdInstockService.cs | 8 ++
.../Tnb.ProductionMgr/PrdInstockService.cs | 110 ++++++++++++++++++
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 24 ++--
3 files changed, 135 insertions(+), 7 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
index 5cca73d3..9f0cb544 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
@@ -1,3 +1,4 @@
+using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.ProductionMgr.Interfaces
@@ -28,5 +29,12 @@ namespace Tnb.ProductionMgr.Interfaces
///
///
public Task InstockTypeOne(InstockInput inut);
+
+ ///
+ /// 短管挤出入库申请
+ ///
+ ///
+ ///
+ public Task InstockTubeOne(PrdReport prdReport);
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
index a854e8d2..0ae748de 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
@@ -389,5 +389,115 @@ namespace Tnb.ProductionMgr
if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
}
+
+ [HttpPost]
+ public async Task InstockTubeOne(PrdReport prdReport)
+ {
+ var db = _repository.AsSugarClient();
+ string location_code = "JMXHC-01";
+ string warehouse_id = "26103348825381";
+
+ PrdInstockH prdInstockH = null;
+ List prdInstockDs = new List() { };
+ DbResult result2 = new DbResult();
+ BasMaterial basMaterial = await db.Queryable().SingleAsync(x=>x.id==prdReport.material_id);
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
+ OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode);
+
+ prdInstockH = new PrdInstockH()
+ {
+ bill_type = DictConst.CHANCHENGPINRUKUDAN,
+ bill_date = DateTime.Now,
+ create_id = _userManager.UserId,
+ location_code = location_code,
+ carry_code = prdReport.material_box_code,
+ is_check = 1,
+ station_id = prdReport.station,
+ workline_id = workline?.Id ?? "",
+ workshop_id = workshop?.Id ?? "",
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ warehouse_id = warehouse_id,
+ status = 0,
+ };
+
+ prdInstockDs.Add(new PrdInstockD()
+ {
+ instock_id = prdInstockH.id,
+ report_id = prdReport.create_id,
+ material_id = prdReport.material_id,
+ material_code = basMaterial.code,
+ unit_id = prdReport.unit_id,
+ barcode = prdReport.barcode,
+ code_batch = prdReport.barcode+"0001",
+ quantity = (int)prdReport.reported_qty,
+ });
+ });
+
+ if (result.IsSuccess)
+ {
+ MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
+ mesCreateInstockInput.instock = new MESWmsInstockHInput()
+ {
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ bill_date = DateTime.Now,
+ bill_type = DictConst.CHANCHENGPINRUKUDAN,
+ warehouse_id = warehouse_id,
+ source_id = prdInstockH.id,
+ create_id = _userManager.UserId,
+ carry_code = prdReport.material_box_code,
+ location_code = location_code,
+ is_check = 1,
+ };
+ mesCreateInstockInput.instockds = new List();
+ mesCreateInstockInput.instockcodes = new List();
+ mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
+ {
+ material_id = prdReport.material_id,
+ material_code = basMaterial.code,
+ unit_id = prdReport.unit_id,
+ code_batch = prdReport.barcode,
+ pr_qty = (int)prdReport.reported_qty,
+ });
+
+ mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
+ {
+ material_id = prdReport.material_id,
+ material_code = basMaterial.code,
+ unit_id = prdReport.unit_id,
+ barcode = prdReport.barcode,
+ code_batch = prdReport.barcode+"0001",
+ codeqty = (int)prdReport.reported_qty,
+ });
+ string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
+ Dictionary header = new Dictionary()
+ {
+ ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
+ };
+ var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
+ Log.Information(sendResult);
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200 || !authResponse.data.ObjToBool())
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ result2 = await db.Ado.UseTranAsync(async () =>
+ {
+ await _repository.InsertAsync(prdInstockH);
+
+ if (prdInstockDs.Count > 0)
+ {
+ await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ }
+ });
+
+ }
+ }
+
+ return result2.IsSuccess ? "true" : "false";
+ }
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 5d9d1af0..1a02c437 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -70,6 +70,7 @@ namespace Tnb.ProductionMgr
private static Dictionary _dicProcess = new Dictionary();
private readonly ISqlSugarClient _db;
private readonly IBillRullService _billRuleService;
+ private readonly IPrdInstockService _prdInstockService;
private readonly IQcCheckPlanService _qcCheckPlanService;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
@@ -79,6 +80,7 @@ namespace Tnb.ProductionMgr
IDictionaryDataService dictionaryDataService,
IRunService runService,
IBillRullService billRullService,
+ IPrdInstockService prdInstockService,
IVisualDevService visualDevService,
IQcCheckPlanService qcCheckPlanService
)
@@ -92,6 +94,7 @@ namespace Tnb.ProductionMgr
OverideFuncs.DeleteAsync = Delete;
OverideFuncs.GetListAsync = GetList;
_billRuleService = billRullService;
+ _prdInstockService = prdInstockService;
_qcCheckPlanService=qcCheckPlanService;
}
@@ -1442,12 +1445,12 @@ namespace Tnb.ProductionMgr
public async Task PrdReport(PrdReportCrInput input)
{
var db = _repository.AsSugarClient();
+ var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id);
+ var equip = await db.Queryable().SingleAsync(x=>x.id==prdMoTask.eqp_id);
+ var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var row = -1;
- var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
- var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id);
- var equip = await db.Queryable().SingleAsync(x=>x.id==prdMoTask.eqp_id);
var prdMo = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id);
var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
@@ -1725,13 +1728,20 @@ namespace Tnb.ProductionMgr
// }
// }
- if (equip.tube == "1")
- {
-
- }
+
});
+ if (result.IsSuccess)
+ {
+ if (equip.tube == "1")
+ {
+ string resultMsg = await _prdInstockService.InstockTubeOne(report);
+ if (resultMsg == "true") return true;
+ throw Oops.Bah(resultMsg);
+ }
+ }
+
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess;
}
From e0972cb1b9ad909c0c55f589da9f57b420de1085 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 6 Nov 2023 16:38:23 +0800
Subject: [PATCH 6/6] bug
---
.../Dto/PrdManage/MaterialPreparationPlanOutput.cs | 1 +
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs
index f8c367bd..c8f0b087 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialPreparationPlanOutput.cs
@@ -18,6 +18,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
public string parent_id { get; set; }
public string material_id { get; set; }
public string material_code { get; set; }
+ public string workstation_id { get; set; }
public List children { get; set; } = new List();
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 1a02c437..cda260c3 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -2700,8 +2700,14 @@ namespace Tnb.ProductionMgr
{
string station_id = dic.ContainsKey("station_id") ? dic["station_id"] : "";
if (string.IsNullOrEmpty(station_id)) throw Oops.Bah("工位错误");
-
- return await _db.Queryable().Where(x => x.workstation_id == station_id && x.parent_id!=null && x.mo_task_status==DictConst.InProgressEnCode).FirstAsync();
+ var prdMoTask = await _db.Queryable().Where(x => x.workstation_id == station_id && x.parent_id!=null && x.mo_task_status==DictConst.InProgressEnCode).FirstAsync();
+ if (prdMoTask != null)
+ {
+ BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id);
+ prdMoTask.material_name = basMaterial.name;
+ }
+
+ return prdMoTask;
}
}