Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
Conflicts: WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs
This commit is contained in:
@@ -82,11 +82,11 @@ namespace Tnb.BasicData.Entities.Dto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,10 +67,10 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ public partial class BasEbomD : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,4 +84,9 @@ public partial class BasEbomH : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? query_info { get; set; }
|
public string? query_info { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// erp修改时间
|
||||||
|
/// </summary>
|
||||||
|
public string erp_modify_time { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,4 +278,9 @@ public partial class BasMaterial : BaseEntity<string>
|
|||||||
/// 物料型号
|
/// 物料型号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? material_standard { get; set; }
|
public string? material_standard { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// erp修改时间
|
||||||
|
/// </summary>
|
||||||
|
public string erp_modify_time { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ public partial class BasMbomInput : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ public partial class BasMbomOutput : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace Tnb.BasicData
|
|||||||
material_id_id = b.id,
|
material_id_id = b.id,
|
||||||
status = SqlFunc.IIF(a.status == "0", "禁用", "启用"),
|
status = SqlFunc.IIF(a.status == "0", "禁用", "启用"),
|
||||||
descrip = a.descrip,
|
descrip = a.descrip,
|
||||||
quantity = a.quantity,
|
// quantity = a.quantity,
|
||||||
version = a.version,
|
version = a.version,
|
||||||
route_id = c.name,
|
route_id = c.name,
|
||||||
route_id_id = c.id,
|
route_id_id = c.id,
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分子
|
/// 比列分子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int molecule { get; set; }
|
public decimal molecule { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 比列分母
|
/// 比列分母
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int denominator { get; set; }
|
public decimal denominator { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity
|
||||||
|
{
|
||||||
|
[SugarTable("BOM_LIST")]
|
||||||
|
public class BomList
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 关联id
|
||||||
|
/// </summary>
|
||||||
|
public string BOMID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string MPRODID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父物料单位
|
||||||
|
/// </summary>
|
||||||
|
public string UNIT { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 版本
|
||||||
|
/// </summary>
|
||||||
|
public string HVERSION { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 子物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string SUBPRODID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 底数
|
||||||
|
/// </summary>
|
||||||
|
public decimal DISHU { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
public decimal BATCHAMOUNT { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public string MODIFIEDTIME { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,5 +52,9 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity
|
|||||||
/// 物料主键+物料主单位
|
/// 物料主键+物料主单位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AID { get; set; }
|
public string AID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public string MODIFIEDTIME { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ using JNPF.DynamicApiController;
|
|||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
using JNPF.Message.Service;
|
using JNPF.Message.Service;
|
||||||
|
using JNPF.Systems.Entitys.System;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.TaskScheduler;
|
using JNPF.TaskScheduler;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
@@ -92,8 +93,10 @@ namespace Tnb.ProductionMgr
|
|||||||
throw Oops.Bah($"系统中无法找到物料清单{item.ebom_version}版本");
|
throw Oops.Bah($"系统中无法找到物料清单{item.ebom_version}版本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DictionaryDataEntity unitDic = await _db.Queryable<DictionaryDataEntity>().Where(x=>x.DictionaryTypeId==WmsWareHouseConst.UNITTYPEID && x.EnCode==item.unit_id).FirstAsync();
|
||||||
|
|
||||||
item.id = SnowflakeIdHelper.NextId();
|
item.id = SnowflakeIdHelper.NextId();
|
||||||
|
item.material_id = basMaterial.id;
|
||||||
item.mo_source = "1";
|
item.mo_source = "1";
|
||||||
item.mo_type = moTypeDic[item.mo_type];
|
item.mo_type = moTypeDic[item.mo_type];
|
||||||
item.mo_code = item.mo_code;
|
item.mo_code = item.mo_code;
|
||||||
@@ -103,6 +106,7 @@ namespace Tnb.ProductionMgr
|
|||||||
item.erp_mo_pk = item.erp_mo_pk;
|
item.erp_mo_pk = item.erp_mo_pk;
|
||||||
item.erp_line_pk = item.erp_line_pk;
|
item.erp_line_pk = item.erp_line_pk;
|
||||||
item.erp_lineno = item.erp_lineno;
|
item.erp_lineno = item.erp_lineno;
|
||||||
|
item.unit_id = unitDic?.Id ?? item.unit_id;
|
||||||
|
|
||||||
moList.Add(item);
|
moList.Add(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ namespace Tnb.ProductionMgr
|
|||||||
foreach (BasEbomD item in basEbomDs)
|
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);
|
decimal? num1 = beforeReportNum / (item.molecule/item.denominator);
|
||||||
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
||||||
.LeftJoin<PrdFeedingH>((a, b) => a.feeding_id == b.id)
|
.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)
|
.Where((a, b) => a.material_id == item.material_id && b.mo_task_id == mo_task_id)
|
||||||
@@ -775,7 +775,7 @@ namespace Tnb.ProductionMgr
|
|||||||
else
|
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);
|
decimal? num2 = prdReport.reported_qty / (item.molecule/item.denominator);
|
||||||
if (sum2 <= num2)
|
if (sum2 <= num2)
|
||||||
{
|
{
|
||||||
prdFeedingIds.Add(item.id);
|
prdFeedingIds.Add(item.id);
|
||||||
@@ -1094,7 +1094,7 @@ namespace Tnb.ProductionMgr
|
|||||||
foreach (PrdReport prdReport in prdReports)
|
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);
|
decimal needNum = (prdReport.reported_qty ?? 0) / (basEbomD.molecule/basEbomD.denominator);
|
||||||
if (beforeIn - needNum >= 0)
|
if (beforeIn - needNum >= 0)
|
||||||
{
|
{
|
||||||
beforeIn -= needNum;
|
beforeIn -= needNum;
|
||||||
|
|||||||
@@ -773,22 +773,40 @@ namespace Tnb.ProductionMgr
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<String> SyncBaseData()
|
public async Task<String> SyncBaseData()
|
||||||
{
|
{
|
||||||
var mysqlDb = _db.AsTenant().GetConnection("erpdb");
|
try
|
||||||
List<ErpBdMaterial> list = await mysqlDb.Queryable<ErpBdMaterial>().ToListAsync();
|
{
|
||||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>x.table_name=="base_dictionarydata").ToListAsync();
|
string[] tables = new[] { "base_dictionarydata", "bas_material" };
|
||||||
Dictionary<string,object> unitDic = await _db.Queryable<DictionaryDataEntity>().Where(x=>x.DictionaryTypeId==WmsWareHouseConst.UNITTYPEID).ToDictionaryAsync(x=>x.Id,y=>y.EnCode);
|
var erpdb = _db.AsTenant().GetConnection("erpdb");
|
||||||
|
List<ErpBdMaterial> list = await erpdb.Queryable<ErpBdMaterial>().ToListAsync();
|
||||||
|
List<BomList> bomList = erpdb.Queryable<BomList>().ToList();
|
||||||
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>()
|
||||||
|
.Where(x => tables.Contains(x.table_name)).ToListAsync();
|
||||||
|
Dictionary<string, object> unitDic = await _db.Queryable<DictionaryDataEntity>()
|
||||||
|
.Where(x => x.DictionaryTypeId == WmsWareHouseConst.UNITTYPEID)
|
||||||
|
.ToDictionaryAsync(x => x.Id, y => y.EnCode);
|
||||||
|
Dictionary<string, object> unitDic2 = await _db.Queryable<DictionaryDataEntity>()
|
||||||
|
.Where(x => x.DictionaryTypeId == WmsWareHouseConst.UNITTYPEID)
|
||||||
|
.ToDictionaryAsync(x => x.FullName, y => y.EnCode);
|
||||||
List<BasMaterial> materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
List<BasMaterial> materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||||
|
List<BasEbomH> basEbomHs = await _db.Queryable<BasEbomH>().ToListAsync();
|
||||||
List<BasMaterial> insertMaterial = new List<BasMaterial>();
|
List<BasMaterial> insertMaterial = new List<BasMaterial>();
|
||||||
List<BasMaterialUnit> insertMaterialUnits = new List<BasMaterialUnit>();
|
List<BasMaterialUnit> insertMaterialUnits = new List<BasMaterialUnit>();
|
||||||
|
List<BasEbomH> insertBasEbomHs = new List<BasEbomH>();
|
||||||
|
List<BasEbomD> insertBasEbomDs = new List<BasEbomD>();
|
||||||
List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
|
List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
|
||||||
|
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
foreach (ErpBdMaterial erpBdMaterial in list)
|
foreach (ErpBdMaterial erpBdMaterial in list)
|
||||||
{
|
|
||||||
if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID))
|
|
||||||
{
|
{
|
||||||
string unitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.PK_MEASDOC)?.table_id ?? "";
|
string unitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.PK_MEASDOC)?.table_id ?? "";
|
||||||
unitId = unitDic.ContainsKey(unitId) ? unitDic[unitId].ToString() : "";
|
unitId = unitDic.ContainsKey(unitId) ? unitDic[unitId].ToString() : "";
|
||||||
string auxiliaryUnitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.FMEASDOC)?.table_id ?? "";
|
string auxiliaryUnitId =
|
||||||
|
erpExtendFields.Find(x => x.cunitid == erpBdMaterial.FMEASDOC)?.table_id ?? "";
|
||||||
auxiliaryUnitId = unitDic.ContainsKey(auxiliaryUnitId) ? unitDic[auxiliaryUnitId].ToString() : "";
|
auxiliaryUnitId = unitDic.ContainsKey(auxiliaryUnitId) ? unitDic[auxiliaryUnitId].ToString() : "";
|
||||||
|
string[] unitArr = erpBdMaterial.MEASRATE.Split("/");
|
||||||
|
if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID))
|
||||||
|
{
|
||||||
BasMaterial basMaterial = new BasMaterial()
|
BasMaterial basMaterial = new BasMaterial()
|
||||||
{
|
{
|
||||||
id = SnowflakeIdHelper.NextId(),
|
id = SnowflakeIdHelper.NextId(),
|
||||||
@@ -799,10 +817,12 @@ namespace Tnb.ProductionMgr
|
|||||||
material_standard = erpBdMaterial.MATERIALTYPE,
|
material_standard = erpBdMaterial.MATERIALTYPE,
|
||||||
category_id = "[\"CGJCJ\"]",
|
category_id = "[\"CGJCJ\"]",
|
||||||
unit_id = unitId,
|
unit_id = unitId,
|
||||||
|
create_time = DateTime.Now
|
||||||
};
|
};
|
||||||
insertMaterial.Add(basMaterial);
|
insertMaterial.Add(basMaterial);
|
||||||
|
|
||||||
string[] unitArr = erpBdMaterial.MEASRATE.Split("/");
|
if (unitId != auxiliaryUnitId)
|
||||||
|
{
|
||||||
insertMaterialUnits.Add(new BasMaterialUnit()
|
insertMaterialUnits.Add(new BasMaterialUnit()
|
||||||
{
|
{
|
||||||
id = SnowflakeIdHelper.NextId(),
|
id = SnowflakeIdHelper.NextId(),
|
||||||
@@ -813,7 +833,181 @@ namespace Tnb.ProductionMgr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "true";
|
else
|
||||||
|
{
|
||||||
|
ErpExtendField extendField = erpExtendFields.Find(x => x.cmaterialoid == erpBdMaterial.ID);
|
||||||
|
string materialId = extendField?.table_id ?? "";
|
||||||
|
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().SingleAsync(x => x.id == materialId);
|
||||||
|
if (erpBdMaterial.MODIFIEDTIME != basMaterial.erp_modify_time)
|
||||||
|
{
|
||||||
|
int updateRow = await _db.Updateable<BasMaterial>()
|
||||||
|
.SetColumns(x => x.name == erpBdMaterial.NAME)
|
||||||
|
.SetColumns(x => x.code == erpBdMaterial.CODE)
|
||||||
|
.SetColumns(x => x.material_specification == erpBdMaterial.MATERIALSPEC)
|
||||||
|
.SetColumns(x => x.material_standard == erpBdMaterial.MATERIALTYPE)
|
||||||
|
.SetColumns(x => x.unit_id == unitId)
|
||||||
|
.SetColumns(x => x.name == erpBdMaterial.NAME)
|
||||||
|
.SetColumns(x => x.erp_modify_time == erpBdMaterial.MODIFIEDTIME)
|
||||||
|
.Where(x => x.id == materialId)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
if (updateRow <= 0)
|
||||||
|
{
|
||||||
|
Log.Error($"未找到物料{erpBdMaterial.ID},跳过此条数据");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasMaterialUnit basMaterialUnit = await _db.Queryable<BasMaterialUnit>()
|
||||||
|
.Where(x => x.material_id == materialId && x.auxiliary_unit_id == auxiliaryUnitId)
|
||||||
|
.FirstAsync();
|
||||||
|
if (basMaterialUnit == null)
|
||||||
|
{
|
||||||
|
if (unitId != auxiliaryUnitId)
|
||||||
|
{
|
||||||
|
insertMaterialUnits.Add(new BasMaterialUnit()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
material_id = materialId,
|
||||||
|
number_of_primary_unit = unitArr[0],
|
||||||
|
number_of_auxiliary_unit = unitArr[1],
|
||||||
|
auxiliary_unit_id = auxiliaryUnitId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (unitId != auxiliaryUnitId)
|
||||||
|
{
|
||||||
|
await _db.Updateable<BasMaterialUnit>()
|
||||||
|
.SetColumns(x => x.number_of_primary_unit == unitArr[0])
|
||||||
|
.SetColumns(x => x.number_of_auxiliary_unit == unitArr[1])
|
||||||
|
.Where(x => x.id == basMaterialUnit.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Insertable(insertMaterial).ExecuteCommandAsync();
|
||||||
|
await _db.Insertable(insertMaterialUnits).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
//物料清单开始同步
|
||||||
|
materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||||
|
var groupList = bomList.GroupBy(x => x.BOMID);
|
||||||
|
foreach (var item in groupList)
|
||||||
|
{
|
||||||
|
string key = item.Key;
|
||||||
|
List<BomList> itemList = item.ToList();
|
||||||
|
BomList firstItemInList = itemList[0];
|
||||||
|
BasMaterial material = materials.Find(x => x.code==firstItemInList.MPRODID);
|
||||||
|
if (material == null) continue;
|
||||||
|
string unitId = unitDic.ContainsKey(firstItemInList.UNIT) ? unitDic[firstItemInList.UNIT].ToString() : "";
|
||||||
|
if (basEbomHs.All(x => x.material_id != material.id && x.version != firstItemInList.HVERSION))
|
||||||
|
{
|
||||||
|
BasEbomH basEbomH = new BasEbomH()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
org_id = WmsWareHouseConst.AdministratorOrgId,
|
||||||
|
material_id = material.id,
|
||||||
|
unit_id = unitId,
|
||||||
|
version = firstItemInList.HVERSION,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool flag = false;
|
||||||
|
List<BasEbomD> tempList = new List<BasEbomD>();
|
||||||
|
foreach (var children in itemList)
|
||||||
|
{
|
||||||
|
BasMaterial childrenMaterial = materials.Find(x => x.code==children.SUBPRODID);
|
||||||
|
if (childrenMaterial == null)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
tempList = new List<BasEbomD>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasEbomD basEbomD = new BasEbomD()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
ebom_id = basEbomH.id,
|
||||||
|
material_id = childrenMaterial.id,
|
||||||
|
denominator = children.DISHU,
|
||||||
|
molecule = children.BATCHAMOUNT,
|
||||||
|
};
|
||||||
|
tempList.Add(basEbomD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertBasEbomHs.Add(basEbomH);
|
||||||
|
insertBasEbomDs.AddRange(tempList);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BasEbomH basEbomH = await _db.Queryable<BasEbomH>().Where(x=>x.material_id==material.id && x.version==firstItemInList.HVERSION).FirstAsync();
|
||||||
|
if (basEbomH == null) continue;
|
||||||
|
|
||||||
|
if (basEbomH.erp_modify_time != firstItemInList.MODIFIEDTIME)
|
||||||
|
{
|
||||||
|
bool flag = false;
|
||||||
|
List<BasEbomD> tempList = new List<BasEbomD>();
|
||||||
|
foreach (var children in itemList)
|
||||||
|
{
|
||||||
|
BasMaterial childrenMaterial = materials.Find(x => x.code==children.SUBPRODID);
|
||||||
|
if (childrenMaterial == null)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
tempList = new List<BasEbomD>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasEbomD basEbomD = new BasEbomD()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
ebom_id = basEbomH.id,
|
||||||
|
material_id = childrenMaterial.id,
|
||||||
|
denominator = children.DISHU,
|
||||||
|
molecule = children.BATCHAMOUNT,
|
||||||
|
};
|
||||||
|
tempList.Add(basEbomD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertBasEbomDs.AddRange(tempList);
|
||||||
|
await _db.Updateable<BasEbomH>()
|
||||||
|
.SetColumns(x => x.unit_id == unitId)
|
||||||
|
.Where(x => x.id == basEbomH.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
await _db.Deleteable<BasEbomD>().Where(x => x.ebom_id == basEbomH.id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Insertable(insertBasEbomHs).ExecuteCommandAsync();
|
||||||
|
await _db.Insertable(insertBasEbomDs).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e.Message, e);
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -942,14 +942,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (input.area_code == "E")
|
if (input.area_code == "E")
|
||||||
await sign(input);
|
await sign(input);
|
||||||
|
|
||||||
|
|
||||||
// 其它入库
|
// 其它入库
|
||||||
if (input.wmsDistaskH.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID)
|
if (input.wmsDistaskH.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID)
|
||||||
{
|
{
|
||||||
|
Logger.LogInformation("【WmsMaterialTransferService ModifyAsync】同步其它入库单到erp...");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// 其它出库
|
// 其它出库
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Logger.LogInformation("【WmsMaterialTransferService ModifyAsync】同步其它出库单到erp...");
|
||||||
|
|
||||||
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id);
|
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id);
|
||||||
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();
|
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();
|
||||||
DictionaryDataEntity unitData = await _db.Queryable<DictionaryTypeEntity>()
|
DictionaryDataEntity unitData = await _db.Queryable<DictionaryTypeEntity>()
|
||||||
@@ -1006,7 +1011,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
["crowno"] = wmsMaterialTransferd.lineno,
|
["crowno"] = wmsMaterialTransferd.lineno,
|
||||||
["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk,
|
["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk,
|
||||||
["csourcebillhid"] = wmsMaterialTransfer.erp_pk,
|
["csourcebillhid"] = wmsMaterialTransfer.erp_pk,
|
||||||
["cunitid"] = erpExtendFields.Find(x => x.table_id == unitData.Id)?.cunitid ?? "",
|
["cunitid"] = erpExtendFields.Find(x => x.table_id == unitData?.Id)?.cunitid ?? "",
|
||||||
["cvendorid"] = "",
|
["cvendorid"] = "",
|
||||||
["cvendorvid"] = "",
|
["cvendorvid"] = "",
|
||||||
["dbizdate"] = nowStr,
|
["dbizdate"] = nowStr,
|
||||||
@@ -1030,6 +1035,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
thirdWebapiRecord.create_time = DateTime.Now;
|
thirdWebapiRecord.create_time = DateTime.Now;
|
||||||
|
|
||||||
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
||||||
|
Logger.LogInformation("【WmsMaterialTransferService ModifyAsync】同步其它出库单到erp成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user