| | |
| | | var single = base.GetSingle(it => it.Erpid == entity.Erpid); |
| | | if (single != null) entity.Guid = single.Guid; |
| | | |
| | | // 查找并设置对应的MES系统ID |
| | | // CAA021 工作车间 -> SYS_DEPARTMENT.id |
| | | if (!string.IsNullOrEmpty(entity.Caa021)) |
| | | { |
| | | var department = Db.Queryable<SysDepartment>() |
| | | .Where(d => d.Departmentcode == entity.Caa021) |
| | | .Select(d => d.Id) |
| | | .First(); |
| | | entity.Caa021 = department.ToString(); |
| | | } |
| | | |
| | | // DEPOT_CODE 仓库 -> MES_DEPOTS.id |
| | | if (!string.IsNullOrEmpty(entity.DepotCode)) |
| | | { |
| | | var depot = Db.Queryable<MesDepots>() |
| | | .Where(d => d.DepotCode == entity.DepotCode) |
| | | .Select(d => d.DepotId) |
| | | .First(); |
| | | entity.DepotCode = depot.ToString(); |
| | | } |
| | | |
| | | // ERP_WTZZ 委托组织 -> 1 (固定值) |
| | | entity.ErpWtzz = 1; |
| | | |
| | | // ERP_SCZZ 生产组织 -> 1 (固定值) |
| | | entity.ErpSczz = 1; |
| | | |
| | | // CAA006 产品编码 -> MES_ITEMS.id |
| | | if (!string.IsNullOrEmpty(entity.Caa006)) |
| | | { |
| | | var item = Db.Queryable<MesItems>() |
| | | .Where(i => i.ItemNo == entity.Caa006) |
| | | .Select(i => i.Id) |
| | | .First(); |
| | | entity.Caa006 = item.ToString(); |
| | | } |
| | | |
| | | // CAA009 单位 -> MES_UNIT.id |
| | | if (!string.IsNullOrEmpty(entity.Caa009)) |
| | | { |
| | | var unit = Db.Queryable<MesUnit>() |
| | | .Where(u => u.Fnumber == entity.Caa009) |
| | | .Select(u => u.Id) |
| | | .First(); |
| | | entity.Caa009 = unit.ToString(); |
| | | } |
| | | |
| | | return entity; |
| | | } |
| | | |