| | |
| | | using SqlSugar; |
| | | |
| | | namespace MES.Service.service.BasicData; |
| | | |
| | | /// <summary> |
| | | /// 物料信息 |
| | | /// </summary> |
| | | public class MesItemsManager : Repository<MesItems> |
| | | { |
| | | public bool Save(ErpItems item) |
| | |
| | | ItemNo = item.FNumber, |
| | | ItemName = item.FName, |
| | | ItemModel = item.FSpecification, |
| | | ItemUnit = item.FBaseUnitId, |
| | | ItemUnit = item.FBaseUnitId,//物料基本单位编码转ID |
| | | Lowlimit = Convert.ToDouble(item.FSafeStock), |
| | | Highlimit = Convert.ToDouble(item.FMaxStock), |
| | | PrdPack = Convert.ToDouble(item.FMinPackCount), |
| | |
| | | Remarks = item.FDescription, |
| | | Ffinishreceiptoverrate = |
| | | Convert.ToDecimal(item.FFinishReceiptOverRate), |
| | | Fissuetype = item.FIssueType, |
| | | //发料方式 |
| | | Fissuetype = item.FIssueType switch |
| | | { |
| | | "1" => "逐批领料", |
| | | "2" => "自动扣料", |
| | | _ => item.FIssueType |
| | | }, |
| | | //Fissuetype = item.FIssueType, |
| | | |
| | | //批号管理 |
| | | Fisbatchmanage = item.FIsBatchManage switch |
| | | { |
| | |
| | | Fpurchaseunitid = item.FPurchaseUnitId, |
| | | Storeunit = item.FStoreUnitID, |
| | | Saleunit = item.FSaleUnitId, |
| | | //Fforbidstatus = item.FForbidStatus, |
| | | Fforbidstatus = item.FForbidStatus,//启用与禁用 |
| | | MaterialProperti = item.FErpClsID, |
| | | ProductionWorkshop = item.FWorkShopId, |
| | | ProduceUnit = item.FPRODUCEUNITID, |
| | | SubconUnit = item.FSUBCONUNITID, |
| | | FSubsidiary = item.FUseOrgId, |
| | | Fumbrella = item.FCreateOrgId, |
| | | //FSubsidiary = item.FUseOrgId, |
| | | //Fumbrella = item.FCreateOrgId, |
| | | LastupdateDate = DateTime.Now, |
| | | // 如果存在,使用现有的CreateDate,后续将删除后重新插入 |
| | | // 如果不存在,设为当前时间 |
| | |
| | | ExpirationDate= item.Expirationdate, |
| | | ReviewPeriod= item.Reviewperiod, |
| | | LeadDays= item.FLeadDays, |
| | | Remark5 = item.FRemark5 |
| | | }; |
| | | Remark5 = item.FRemark5, |
| | | |
| | | // ERP: 0=未禁用, 1=禁用 |
| | | // MES: A=未禁用, B=禁用 |
| | | if (string.IsNullOrEmpty(item.FForbidStatus)) |
| | | FSubsidiary = string.IsNullOrEmpty(item.FUseOrgId) ? "1" : item.FUseOrgId, |
| | | Fumbrella = string.IsNullOrEmpty(item.FCreateOrgId) ? "1" : item.FCreateOrgId, |
| | | }; |
| | | //物料基本单位编码转ID,ItemUnit = item.FBaseUnitId |
| | | var entityItemUnit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FBaseUnitId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityItemUnit)) |
| | | { |
| | | entity.Fforbidstatus = "A"; |
| | | entity.ItemUnit = entityItemUnit; |
| | | } |
| | | else |
| | | { |
| | | //我期望的值是A=否,B=是 |
| | | //实际给我的值是0或1,我希望为我转换从A和B的方式 |
| | | entity.Fforbidstatus = item.FForbidStatus == "1" ? "B" : "A"; |
| | | entity.ItemUnit = "0"; |
| | | } |
| | | |
| | | //物料销售单位编码转ID,Saleunit = item.FSaleUnitId |
| | | var entitySaleunit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FSaleUnitId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entitySaleunit)) |
| | | { |
| | | entity.Saleunit = entitySaleunit; |
| | | } |
| | | else |
| | | { |
| | | entity.Saleunit = "0"; |
| | | } |
| | | |
| | | //物料库房单位编码转ID,Storeunit = item.FStoreUnitID |
| | | var entityStoreunit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FStoreUnitID) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityStoreunit)) |
| | | { |
| | | entity.Storeunit = entityStoreunit; |
| | | } |
| | | else |
| | | { |
| | | entity.Storeunit = "0"; |
| | | } |
| | | |
| | | //物料采购单位编码转ID,Fpurchaseunitid = item.FPurchaseUnitId |
| | | var entityFpurchaseunitid = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FPurchaseUnitId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityFpurchaseunitid)) |
| | | { |
| | | entity.Fpurchaseunitid = entityFpurchaseunitid; |
| | | } |
| | | else |
| | | { |
| | | entity.Fpurchaseunitid = "0"; |
| | | } |
| | | |
| | | //物料生产单位编码转ID,ProduceUnit = item.FPRODUCEUNITID |
| | | var entityProduceUnit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FPRODUCEUNITID) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityProduceUnit)) |
| | | { |
| | | entity.ProduceUnit = entityProduceUnit; |
| | | } |
| | | else |
| | | { |
| | | entity.ProduceUnit = "0"; |
| | | } |
| | | |
| | | //物料委外单位编码转ID,SubconUnit = item.FSUBCONUNITID |
| | | var entitySubconUnit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == item.FSUBCONUNITID) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entitySubconUnit)) |
| | | { |
| | | entity.SubconUnit = entitySubconUnit; |
| | | } |
| | | else |
| | | { |
| | | entity.SubconUnit = "0"; |
| | | } |
| | | |
| | | //默认仓库编码转ID,DepotCode = item.FStockId, |
| | | var entityDepotCode = Db.Queryable<MesDepots>() |
| | | .Where(x => x.DepotCode == item.FStockId) |
| | | .Select(x => x.DepotId.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityDepotCode)) |
| | | { |
| | | entity.DepotCode = entityDepotCode; |
| | | } |
| | | else |
| | | { |
| | | entity.DepotCode = "0"; |
| | | } |
| | | |
| | | //采购员编码转ID,Fpurchaserid = item.FPurchaserId, |
| | | var entityFpurchaserid = Db.Queryable<MesStaff>() |
| | | .Where(x => x.StaffNo == item.FPurchaserId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityFpurchaserid)) |
| | | { |
| | | entity.Fpurchaserid = entityFpurchaserid; |
| | | } |
| | | else |
| | | { |
| | | entity.Fpurchaserid = "0"; |
| | | } |
| | | |
| | | //工作中心编码转ID,ProductionWorkshop = item.FWorkShopId, |
| | | var entityProductionWorkshop = Db.Queryable<SysDepartment>() |
| | | .Where(x => x.WorkshopCenterCode == item.FWorkShopId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityProductionWorkshop)) |
| | | { |
| | | entity.ProductionWorkshop = entityProductionWorkshop; |
| | | } |
| | | else |
| | | { |
| | | entity.ProductionWorkshop = "0"; |
| | | } |
| | | |
| | | //// ERP: Y=未禁用, N=禁用 |
| | | //// MES: A=未禁用, B=禁用 |
| | | //if (string.IsNullOrEmpty(item.FForbidStatus)) |
| | | //{ |
| | | // entity.Fforbidstatus = "A"; |
| | | //} |
| | | //else |
| | | //{ |
| | | // //我期望的值是A=启用,B=禁用 |
| | | // //实际给我的值是Y或N,我希望为我转换从A和B的方式 |
| | | // entity.Fforbidstatus = item.FForbidStatus == "N" ? "B" : "A"; |
| | | //} |
| | | |
| | | return entity; |
| | | } |
| | |
| | | return newId; |
| | | } |
| | | |
| | | private bool UpdateItemStatusBatch(SqlSugarScope db, |
| | | List<MesItems> itemList, string status) |
| | | private bool UpdateItemStatusBatch(SqlSugarScope db,List<MesItems> itemList, string status) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesItems>() |