diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs
index 49d1e25d..d525f56e 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMaterialReceiptRecordUpListOutPut.cs
@@ -17,6 +17,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
{
public string id { get; set; }
public string code { get; set; }
+ public string carry_code { get; set; }
public string create_id { get; set; }
public string create_time { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs
new file mode 100644
index 00000000..fff0a467
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs
@@ -0,0 +1,40 @@
+using JNPF.Common.Contracts;
+using SqlSugar;
+
+namespace Tnb.ProductionMgr.Entities.Entity
+{
+ ///
+ /// erp扩展字段
+ ///
+ [SugarTable("erp_extend_field")]
+ public class ErpExtendField: BaseEntity
+ {
+ ///
+ /// 天益表名
+ ///
+ public string table_name { get; set; }
+ ///
+ /// 天益表id
+ ///
+ public string table_id { get; set; }
+
+ ///
+ /// 机构id
+ ///
+ public string org_id { get; set; }
+ ///
+ /// erp表体行号
+ ///
+ public int erp_lineno { get; set; }
+ ///
+ /// 工单pk值
+ ///
+ public string erp_mo_pk { get; set; }
+ ///
+ /// 表体pk值
+ ///
+ public string erp_line_pk { get; set; }
+
+ public DateTime create_time { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
index e2c03281..8972d2b0 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
@@ -243,5 +243,19 @@ public partial class PrdMo : BaseEntity
///
public string? mo_source { get; set; }
-
+ ///
+ /// erp表体行号
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int erp_lineno { get; set; }
+ ///
+ /// 工单pk值
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string erp_mo_pk { get; set; }
+ ///
+ /// 表体pk值
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string erp_line_pk { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs
index 96236403..24b72972 100644
--- a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs
@@ -1,4 +1,5 @@
using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
@@ -13,6 +14,7 @@ using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Consts;
namespace Tnb.ProductionMgr
@@ -25,6 +27,14 @@ namespace Tnb.ProductionMgr
private readonly IUserManager _userManager;
private readonly IBillRullService _billRuleService;
+ public static Dictionary moTypeDic = new Dictionary()
+ {
+ ["1"] = "25019163616533", //注塑
+ ["2"] = "25019172714005", //挤出
+ ["3"] = "25019181615125", //组装
+ ["4"] = "25019191681045", //包装
+ };
+
public MesForErpService(ISqlSugarRepository repository,
IBillRullService billRuleService,
IUserManager userManager)
@@ -36,45 +46,71 @@ namespace Tnb.ProductionMgr
[HttpPost]
[AllowAnonymous]
- public async Task SavePrdMo(PrdMo input)
+ public async Task SavePrdMo(List input)
{
- if (input == null)
+ if (input == null || input.IsEmpty())
throw Oops.Bah("参数不能为空");
- if(string.IsNullOrEmpty(input.mo_code))
- throw Oops.Bah("工单代码不能为空");
- if(string.IsNullOrEmpty(input.mo_type))
- throw Oops.Bah("工单类型不能为空");
- if(input.plan_start_date==null)
- throw Oops.Bah("计划开始日期不能为空");
- if(input.plan_end_date==null)
- throw Oops.Bah("计划结束日期不能为空");
- if(string.IsNullOrEmpty(input.material_code))
- throw Oops.Bah("物料编号不能为空");
- if(string.IsNullOrEmpty(input.unit_id))
- throw Oops.Bah("单位不能为空");
- if(input.plan_qty==null || input.plan_qty<=0)
- throw Oops.Bah("计划数量不能为空");
- BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.code == input.material_code);
- if(basMaterial==null)
- throw Oops.Bah($"未找到物料编号为{input.material_code}的物料");
+ List moList = new List();
+ List extendFieldList = new List();
+ foreach (var item in input)
+ {
+ if(string.IsNullOrEmpty(item.mo_code))
+ throw Oops.Bah("工单代码不能为空");
+ if(string.IsNullOrEmpty(item.mo_type))
+ throw Oops.Bah("工单类型不能为空");
+ if(item.plan_start_date==null)
+ throw Oops.Bah("计划开始日期不能为空");
+ if(item.plan_end_date==null)
+ throw Oops.Bah("计划结束日期不能为空");
+ if(string.IsNullOrEmpty(item.material_code))
+ throw Oops.Bah("物料编号不能为空");
+ if(string.IsNullOrEmpty(item.unit_id))
+ throw Oops.Bah("单位不能为空");
+ if(item.plan_qty==null || item.plan_qty<=0)
+ throw Oops.Bah("计划数量不能为空");
+ if(item.ebom_version==null || item.ebom_version.IsEmpty())
+ throw Oops.Bah("物料清单版本不能为空");
- List basMaterialUnits = await _db.Queryable().Where(x => x.material_id == basMaterial.id).ToListAsync();
- List units = basMaterialUnits.Select(x => x.auxiliary_unit_id).Distinct().ToList();
- if(units!=null && !string.IsNullOrEmpty(basMaterial.unit_id)) units.Add(basMaterial.unit_id);
+ BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.code == item.material_code);
+ if(basMaterial==null)
+ throw Oops.Bah($"未找到物料编号为{item.material_code}的物料");
+
+ List basMaterialUnits = await _db.Queryable().Where(x => x.material_id == basMaterial.id).ToListAsync();
+ List units = basMaterialUnits.Select(x => x.auxiliary_unit_id).Distinct().ToList();
+ if(units!=null && !string.IsNullOrEmpty(basMaterial.unit_id)) units.Add(basMaterial.unit_id);
- if(!units.Contains(input.unit_id))
- throw Oops.Bah($"{basMaterial.name}不存在{input.unit_id}该单位");
+ if(!units.Contains(item.unit_id))
+ throw Oops.Bah($"{basMaterial.name}不存在{item.unit_id}该单位");
- input.id = SnowflakeIdHelper.NextId();
- input.mo_source = "1";
- input.mo_code = input.mo_code;
- input.create_id = WmsWareHouseConst.AdministratorUserId;
- input.create_time = DateTime.Now;
- input.mo_status = DictConst.ToBeScheduledId;
- await _db.Insertable(input).ExecuteCommandAsync();
- return "true";
-
+ item.id = SnowflakeIdHelper.NextId();
+ item.mo_source = "1";
+ item.mo_type = moTypeDic[item.mo_type];
+ item.mo_code = item.mo_code+"-"+item.erp_lineno;
+ item.create_id = WmsWareHouseConst.AdministratorUserId;
+ item.create_time = DateTime.Now;
+ item.mo_status = DictConst.ToBeScheduledId;
+
+ moList.Add(item);
+ extendFieldList.Add(new ErpExtendField()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ org_id =WmsWareHouseConst.AdministratorOrgId,
+ table_name = "prd_mo",
+ table_id = item.id,
+ erp_lineno = item.erp_lineno,
+ erp_line_pk = item.erp_line_pk,
+ erp_mo_pk = item.erp_mo_pk,
+ create_time = DateTime.Now
+ });
+ }
+ DbResult result = await _db.Ado.UseTranAsync(async () =>
+ {
+ await _db.Insertable(moList).ExecuteCommandAsync();
+ await _db.Insertable(extendFieldList).ExecuteCommandAsync();
+ });
+
+ return !result.IsSuccess ? result.ErrorMessage : "保存成功";
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 36738cde..c7408f87 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -480,7 +480,7 @@ namespace Tnb.ProductionMgr
await db.Updateable()
.SetColumns(x => x.carry_status == ((int)EnumCarryStatus.空闲).ToString())
- .Where(x => x.id==detail.member_carry_id)
+ .Where(x => x.id==input.carry_code)
.ExecuteCommandAsync();
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput()
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs
index 40638ffa..3de5b470 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptRecordUpServicecs.cs
@@ -99,6 +99,7 @@ namespace Tnb.ProductionMgr
{
id = x.id,
code = x.code,
+ carry_code = x.carry_code,
create_id = y.RealName,
create_time = x.create_time==null ? "" : x.create_time.Value.ToString(DbTimeFormat.SS),
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 27ae494c..4c9099f5 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -2071,6 +2071,11 @@ namespace Tnb.ProductionMgr
{
throw Oops.Bah($"提报失败,载具已绑定");
}
+ List wmsCarryCodes = await db.Queryable().Where(x=>x.carry_code==materialBoxCode).ToListAsync();
+ if (wmsCarryCodes != null && wmsCarryCodes.Count > 0)
+ {
+ Log.Error($"载具{materialBoxCode}状态为{wmsCarryH.carry_status},但有条码{JsonConvert.SerializeObject(wmsCarryCodes)}");
+ }
BindCarryCodeInput bindCarryCodeInput = new BindCarryCodeInput();
bindCarryCodeInput.carry_id = wmsCarryH.id;
diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
index afb92632..85420290 100644
--- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
@@ -364,12 +364,14 @@ namespace Tnb.ProductionMgr
bool qu1 = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x1_AGV_qu");
if (qu1)
{
+ Log.Information("血路管1线取");
HttpUtils.RequestGet($"{config.value}/api/production/time-work/x1-auto-prd-report");
}
bool qu2 = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x2_AGV_qu");
if (qu2)
{
+ Log.Information("血路管2线取");
HttpUtils.RequestGet($"{config.value}/api/production/time-work/x2-auto-prd-report");
}
return "true";
@@ -383,11 +385,13 @@ namespace Tnb.ProductionMgr
int num = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x1_Enquantity");
if (string.IsNullOrEmpty(carryCode) || num<=0)
{
+ Log.Information("血路管1线无载具或数量为0");
return "无载具或数量为0";
}
PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.workline_id == WmsWareHouseConst.XUELUGUAN1XIAN && x.mo_task_status == DictConst.InProgressEnCode && x.parent_id != null).FirstAsync();
if (prdMoTask == null)
{
+ Log.Information("血路管1线没有进行中的任务单");
return "血路管1线没有进行中的任务单";
}
@@ -409,11 +413,13 @@ namespace Tnb.ProductionMgr
int num = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x2_Enquantity");
if (string.IsNullOrEmpty(carryCode) || num<=0)
{
+ Log.Information("血路管2线无载具或数量为0");
return "无载具或数量为0";
}
PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.workline_id == WmsWareHouseConst.XUELUGUAN2XIAN && x.mo_task_status == DictConst.InProgressEnCode && x.parent_id != null).FirstAsync();
if (prdMoTask == null)
{
+ Log.Information("血路管2线没有进行中的任务单");
return "血路管2线没有进行中的任务单";
}