Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -38,5 +38,7 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public string MODIFIEDTIME { get; set; }
|
||||
|
||||
// public int ROWNO { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2150,14 +2150,14 @@ namespace Tnb.ProductionMgr
|
||||
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||
{
|
||||
["bbchkflag"] = "N",
|
||||
["bbhasbckfled"] = "N",
|
||||
["bbhaspicked"] = "N",
|
||||
["bbinstock"] = "N",
|
||||
["bbisempass"] = "N",
|
||||
["bbotherreject"] = "N",
|
||||
["bbsetmark"] = "N",
|
||||
["bbstockbycheck"] = "N",
|
||||
["bbchkflag"] = false,
|
||||
["bbhasbckfled"] = false,
|
||||
["bbhaspicked"] = false,
|
||||
["bbinstock"] = false,
|
||||
["bbisempass"] = false,
|
||||
["bbotherreject"] = false,
|
||||
["bbsetmark"] = false,
|
||||
["bbstockbycheck"] = false,
|
||||
["cbastunitid"] = "",
|
||||
["cbbomversionid"] = "",
|
||||
["cbdeptid"] = "",
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<PerProcessStandardsH>((a, b, c, d, e, f, g, h) => a.material_id == h.output_material_id && a.eqp_id == h.equip_id && a.mold_id == h.molds_id && h.enabled == 1)
|
||||
.LeftJoin<BasStandardTime>((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1 && a.schedule_type==1)
|
||||
.LeftJoin<PrdMo>((a, b, c, d, e, f, g, h, i, j) => a.mo_id == j.id)
|
||||
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg")
|
||||
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "KGM")
|
||||
.LeftJoin<EqpDaq>((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求
|
||||
// .Where((a, b) => a.workstation_id == input.stationId)
|
||||
.Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || (a.schedule_type==2 && a.parent_id!=null)))
|
||||
|
||||
@@ -773,12 +773,14 @@ namespace Tnb.ProductionMgr
|
||||
[AllowAnonymous]
|
||||
public async Task<String> SyncBaseData()
|
||||
{
|
||||
string msg = "";
|
||||
try
|
||||
{
|
||||
int editCount = 0;
|
||||
string[] tables = new[] { "base_dictionarydata", "bas_material" };
|
||||
var erpdb = _db.AsTenant().GetConnection("erpdb");
|
||||
List<ErpBdMaterial> list = await erpdb.Queryable<ErpBdMaterial>().ToListAsync();
|
||||
List<BomList> bomList = erpdb.Queryable<BomList>().ToList();
|
||||
List<BomList> bomList = await erpdb.Queryable<BomList>().ToListAsync();
|
||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>()
|
||||
.Where(x => tables.Contains(x.table_name)).ToListAsync();
|
||||
Dictionary<string, object> unitDic = await _db.Queryable<DictionaryDataEntity>()
|
||||
@@ -807,19 +809,39 @@ namespace Tnb.ProductionMgr
|
||||
string[] unitArr = erpBdMaterial.MEASRATE.Split("/");
|
||||
if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID))
|
||||
{
|
||||
BasMaterial basMaterial = new BasMaterial()
|
||||
BasMaterial basMaterial = null;
|
||||
ErpExtendField tempExtendField = insertExtendFields.Find(x => x.cmaterialoid == erpBdMaterial.ID);
|
||||
if (tempExtendField!=null)
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
name = erpBdMaterial.NAME,
|
||||
code = erpBdMaterial.CODE,
|
||||
org_id = WmsWareHouseConst.AdministratorOrgId,
|
||||
material_specification = erpBdMaterial.MATERIALSPEC,
|
||||
material_standard = erpBdMaterial.MATERIALTYPE,
|
||||
category_id = "[\"CGJCJ\"]",
|
||||
unit_id = unitId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
insertMaterial.Add(basMaterial);
|
||||
basMaterial = insertMaterial.Find(x => x.id == tempExtendField.table_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
basMaterial = new BasMaterial()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
name = erpBdMaterial.NAME,
|
||||
code = erpBdMaterial.CODE,
|
||||
org_id = WmsWareHouseConst.AdministratorOrgId,
|
||||
material_specification = erpBdMaterial.MATERIALSPEC,
|
||||
material_standard = erpBdMaterial.MATERIALTYPE,
|
||||
category_id = "[\"CGJCJ\"]",
|
||||
unit_id = unitId,
|
||||
state = "1",
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
insertMaterial.Add(basMaterial);
|
||||
|
||||
ErpExtendField erpExtendField = new ErpExtendField()
|
||||
{
|
||||
table_name = "bas_material",
|
||||
table_id = basMaterial.id,
|
||||
cmaterialoid = erpBdMaterial.ID,
|
||||
cmaterialvid = erpBdMaterial.VID,
|
||||
|
||||
};
|
||||
insertExtendFields.Add(erpExtendField);
|
||||
}
|
||||
|
||||
if (unitId != auxiliaryUnitId)
|
||||
{
|
||||
@@ -850,6 +872,7 @@ namespace Tnb.ProductionMgr
|
||||
.SetColumns(x => x.erp_modify_time == erpBdMaterial.MODIFIEDTIME)
|
||||
.Where(x => x.id == materialId)
|
||||
.ExecuteCommandAsync();
|
||||
editCount += updateRow;
|
||||
if (updateRow <= 0)
|
||||
{
|
||||
Log.Error($"未找到物料{erpBdMaterial.ID},跳过此条数据");
|
||||
@@ -892,6 +915,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
await _db.Insertable(insertMaterial).ExecuteCommandAsync();
|
||||
await _db.Insertable(insertMaterialUnits).ExecuteCommandAsync();
|
||||
await _db.Insertable(insertExtendFields).ExecuteCommandAsync();
|
||||
|
||||
//物料清单开始同步
|
||||
materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||
@@ -903,7 +927,7 @@ namespace Tnb.ProductionMgr
|
||||
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() : "";
|
||||
string unitId = unitDic2.ContainsKey(firstItemInList.UNIT) ? unitDic2[firstItemInList.UNIT].ToString() : "";
|
||||
if (basEbomHs.All(x => x.material_id != material.id && x.version != firstItemInList.HVERSION))
|
||||
{
|
||||
BasEbomH basEbomH = new BasEbomH()
|
||||
@@ -999,6 +1023,8 @@ namespace Tnb.ProductionMgr
|
||||
await _db.Insertable(insertBasEbomDs).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
msg = $"新增物料${insertMaterial.Count}条,修改物料{editCount}条";
|
||||
Log.Information(msg);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1007,7 +1033,7 @@ namespace Tnb.ProductionMgr
|
||||
throw Oops.Bah(e.Message);
|
||||
}
|
||||
|
||||
return "成功";
|
||||
return msg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user