/// <summary> /// 得到某区域所有的固定资产 /// </summary> /// <param name="LocationId">区域编号</param> /// <returns></returns> public DataTable GetAllAss(string LocationId) { var list = _AssetsRepository.GetAll(); if (!string.IsNullOrEmpty(LocationId)) { list = list.Where(a => a.LOCATIONID == LocationId); } list = list.OrderByDescending(a => a.CREATEDATE); var result = from assetse in list join location in SMOSECDbContext.AssLocations on assetse.LOCATIONID equals location.LOCATIONID join type in SMOSECDbContext.AssetsTypes on assetse.TYPEID equals type.TYPEID select new { ASSID = assetse.ASSID, Image = assetse.IMAGE, LocationName = location.NAME, Name = assetse.NAME, Price = assetse.PRICE, SN = assetse.SN, TypeName = type.NAME, Specification = assetse.SPECIFICATION }; return(LINQToDataTable.ToDataTable(result)); }
/// <summary> /// 得到某区域所有的固定资产 /// </summary> /// <param name="LocationId">区域编号</param> /// <returns></returns> public DataTable GetAllAss() { var list = _AssetsRepository.GetAll(); //list = list.OrderByDescending(a => a.id); var result = from assetse in list join location in SMOSECDbContext.AssLocations on assetse.machine_room_id equals location.id join type in SMOSECDbContext.AssetsTypes on assetse.asset_type_id equals type.id join brand in SMOSECDbContext.AssetsBrands on assetse.brand_id equals brand.id select new { uuid = assetse.uuid, //Image = assetse.IMAGE, //DEPARTMENTID = assetse.DEPARTMENTID, //DepName = "", status = assetse.status, StatusName = "", room = location.name, position = assetse.position, //Name = assetse.NAME, //Price = assetse.PRICE, sn = assetse.sn, TypeName = type.name, remark = assetse.remark, Brand = brand.name, }; DataTable table = LINQToDataTable.ToDataTable(result); //foreach (DataRow row in table.Rows) //{ // row["StatusName"] = Enum.GetName(typeof(STATUS), row["status"]); //} return(table); }
/// <summary> /// 得到某区域所有的固定资产 /// </summary> /// <param name="LocationId">区域编号</param> /// <returns></returns> public DataTable GetAllAss(string LocationId) { var list = _AssetsRepository.GetAll().Where(x => x.STATUS != 6); if (!string.IsNullOrEmpty(LocationId)) { list = list.Where(a => a.LOCATIONID == LocationId); } list = list.OrderByDescending(a => a.CREATEDATE); var result = from assetse in list join location in SMOSECDbContext.AssLocations on assetse.LOCATIONID equals location.LOCATIONID join type in SMOSECDbContext.AssetsTypes on assetse.TYPEID equals type.TYPEID select new { ASSID = assetse.ASSID, Image = assetse.IMAGE, DEPARTMENTID = assetse.DEPARTMENTID, DepName = "", Status = assetse.STATUS, StatusName = "", LocationName = location.NAME, Name = assetse.NAME, Price = assetse.PRICE, SN = assetse.SN, TypeName = type.NAME, Specification = assetse.SPECIFICATION }; DataTable table = LINQToDataTable.ToDataTable(result); foreach (DataRow row in table.Rows) { Department dep = _departmentRepository.GetByID(row["DEPARTMENTID"].ToString()).FirstOrDefault(); row["StatusName"] = Enum.GetName(typeof(STATUS), row["Status"]); if (dep != null) { row["DepName"] = dep.NAME; } } return(table); }
/// <summary> /// 得到所有的固定资产 /// </summary> /// <returns></returns> public DataTable GetAllAss(string wareId) { var list = _AssetsRepository.GetAll().Where(a => a.ISINWAREHOUSE == 1); if (!String.IsNullOrEmpty(wareId)) { list = list.Where(a => a.WAREID == wareId); } list = list.OrderByDescending(a => a.CREATEDATE); var result = from assetse in list from location in SMOWMSDbContext.WHStorageLocations from storageType in SMOWMSDbContext.WHStorageTypes from wareHouse in SMOWMSDbContext.WareHouses join type in SMOWMSDbContext.AssetsTypes on assetse.TYPEID equals type.TYPEID where wareHouse.WAREID == assetse.WAREID && storageType.WAREID == assetse.WAREID && storageType.STID == assetse.STID && location.WAREID == assetse.WAREID && location.STID == assetse.STID && location.SLID == assetse.SLID select new { ASSID = assetse.ASSID, Image = assetse.IMAGE, SLName = wareHouse.NAME + "/" + storageType.NAME + "/" + location.NAME, Name = assetse.NAME, Price = assetse.PRICE, SN = assetse.SN, TypeName = type.NAME, Specification = assetse.SPECIFICATION }; return(LINQToDataTable.ToDataTable(result)); }
/// <summary> /// 采购退货 /// </summary> /// <param name="inputDto">采购退货相关信息</param> /// <returns></returns> public ReturnInfo ReturnAss(AssReturnInputDto inputDto) { ReturnInfo RInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); try { //先从Asset表得到属于这个POID的资产的全部SN,放入List<string> var allSn = from instorage in SMOWMSDbContext.AssPurchaseOrderInstorages join assetse in SMOWMSDbContext.Assetss on instorage.SN equals assetse.SN where assetse.ISINWAREHOUSE == 1 && instorage.POID == inputDto.POID select instorage.SN; List <string> allList = allSn.ToList(); //2个List<string>取交集,如果所传的SN都包括,则继续 List <string> bothList = allList.Intersect(inputDto.sns).ToList(); //取出SN在范围内的所有资产 var assets = _assetsRepository.GetAll().Where(a => bothList.Contains(a.SN)); //遍历,修改状态为已不在库 foreach (var asset in assets) { //修改状态为已不在库 asset.ISINWAREHOUSE = 0; _unitOfWork.RegisterDirty(asset); //添加退货关联表 AssPurchaseOrderReturn poReturn = new AssPurchaseOrderReturn { POID = inputDto.POID, SN = asset.SN, TEMPLATEID = asset.TEMPLATEID, // Time = DateTime.Now }; _unitOfWork.RegisterNew(poReturn); var pr = new AssProcessRecord { ASSID = asset.ASSID, CREATEDATE = DateTime.Now, CREATEUSER = inputDto.UserId, HANDLEDATE = DateTime.Now, HANDLEMAN = inputDto.UserId, MODIFYDATE = DateTime.Now, MODIFYUSER = inputDto.UserId, PROCESSCONTENT = inputDto.UserId + "采购退回了" + asset.ASSID + ",数量为1", PROCESSMODE = (int)PROCESSMODE.出库, QUANTITY = 1 }; _unitOfWork.RegisterNew(pr); } var countDictionary = _assetsRepository.GetCountBySnList(bothList); if (countDictionary != null) { foreach (var templateId in countDictionary.Keys) { var asspoRow = _assPoRowRepository.GetByPOIDandTemplateID(inputDto.POID, templateId) .FirstOrDefault(); if (asspoRow != null) { asspoRow.QUANTRETREATED = asspoRow.QUANTRETREATED + countDictionary[templateId]; _unitOfWork.RegisterDirty(asspoRow); } } } bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = ""; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } }
/// <summary> /// 销售退库 /// </summary> /// <param name="inputDto">销售退库相关信息</param> /// <returns></returns> public ReturnInfo RetiringAss(AssRetiringInputDto inputDto) { // ReturnInfo RInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); string ValidateInfo = Helper.BasicValidate(inputDto).ToString(); sb.Append(ValidateInfo); if (sb.Length == 0) { try { //先根据SOID,得到<templateId,List<sn>>的Dictionary //取得各个templateId有多少SN //更改Row中的数值 //更改Assets表中的状态为在库,库位等对应修改 //根据sns,得到<templateId,sn数>的Dictionary string SOID = inputDto.SOID; var allSn = from outbound in SMOWMSDbContext.AssSalesOrderOutbounds join assetse in SMOWMSDbContext.Assetss on outbound.SN equals assetse.SN where assetse.ISINWAREHOUSE == 0 && outbound.SOID == SOID select outbound.SN; List <string> allList = allSn.ToList(); //更改Row中的数值 List <string> bothList = allList.Intersect(inputDto.SnList).ToList(); var assDictionary = _AssetsRepository.GetCountBySnListEx(bothList); foreach (var templateId in assDictionary.Keys) { var row = _assSoRowRepository.GetBySOIDandTemplateID(inputDto.SOID, templateId).FirstOrDefault(); if (row != null) { row.QUANTRETREATED = row.QUANTRETREATED + assDictionary[templateId]; _unitOfWork.RegisterDirty(row); } } //更改Assets表中的状态为在库 var assets = _AssetsRepository.GetAll().Where(a => bothList.Contains(a.SN)); //遍历,修改状态为在库 foreach (var asset in assets) { //修改状态为在库 asset.ISINWAREHOUSE = 1; asset.WAREID = inputDto.WAREID; asset.STID = inputDto.STID; asset.SLID = inputDto.SLID; _unitOfWork.RegisterDirty(asset); //添加出货关联表 AssSalesOrderRetiring soRetiring = new AssSalesOrderRetiring() { SOID = SOID, SN = asset.SN, TEMPLATEID = asset.TEMPLATEID, // Time = DateTime.Now }; _unitOfWork.RegisterNew(soRetiring); var pr = new AssProcessRecord { ASSID = asset.ASSID, CREATEDATE = DateTime.Now, CREATEUSER = inputDto.UserId, HANDLEDATE = DateTime.Now, HANDLEMAN = inputDto.UserId, MODIFYDATE = DateTime.Now, MODIFYUSER = inputDto.UserId, PROCESSCONTENT = inputDto.UserId + "退库了" + asset.ASSID + ",数量为1", PROCESSMODE = (int)PROCESSMODE.退库, QUANTITY = 1 }; _unitOfWork.RegisterNew(pr); } bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = ""; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } } else { RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } }
public List <AssQuantDto> GetAssQuant(QueryAssQuantInputDto inputDto) { var asset = _assetsRepository.GetAll().Where(a => a.ISINWAREHOUSE == 1); if (!string.IsNullOrEmpty(inputDto.WAREID)) { asset = asset.Where(a => a.WAREID == inputDto.WAREID); } var types = (from type1 in SMOWMSDbContext.AssetsTypes where type1.TLEVEL == 1 select new { Level1 = type1.TYPEID, Level2 = "", Level3 = "" }).Union(from type1 in SMOWMSDbContext.AssetsTypes where type1.TLEVEL == 2 select new { Level1 = type1.PARENTTYPEID, Level2 = type1.TYPEID, Level3 = "" }).Union(from type1 in SMOWMSDbContext.AssetsTypes join type2 in SMOWMSDbContext.AssetsTypes on type1.PARENTTYPEID equals type2.TYPEID where type1.TLEVEL == 3 select new { Level1 = type2.PARENTTYPEID, Level2 = type1.PARENTTYPEID, Level3 = type1.TYPEID }); var typelist = types; if (!string.IsNullOrEmpty(inputDto.TYPEID)) { typelist = typelist.Where(a => a.Level1 == inputDto.TYPEID); } var result = from assetse in asset from assTemplate in SMOWMSDbContext.AssTemplates from type in typelist from type1 in SMOWMSDbContext.AssetsTypes join wareHouse in SMOWMSDbContext.WareHouses on assetse.WAREID equals wareHouse.WAREID where assetse.TEMPLATEID == assTemplate.TEMPLATEID && ((assTemplate.TYPEID == type.Level1 && type.Level2 == "") || (assTemplate.TYPEID == type.Level2 && type.Level3 == "") || assTemplate.TYPEID == type.Level3) && type.Level1 == type1.TYPEID select new AssQuantDto() { IMAGE = assTemplate.IMAGE, NAME = assTemplate.NAME, TEMPLATEID = assTemplate.TEMPLATEID, WARENAME = wareHouse.NAME, TYPENAME = type1.NAME, QUANT = 1 }; var fresult = from assQuantDto in result group assQuantDto by new { assQuantDto.TEMPLATEID, assQuantDto.IMAGE, assQuantDto.NAME, assQuantDto.WARENAME, assQuantDto.TYPENAME } into quant select new AssQuantDto() { IMAGE = quant.Key.IMAGE, NAME = quant.Key.NAME, TEMPLATEID = quant.Key.TEMPLATEID, WARENAME = quant.Key.WARENAME, TYPENAME = quant.Key.TYPENAME, QUANT = quant.Count() }; return(fresult.ToList()); }
public DataTable GetAllAss() { return(LINQToDataTable.ToDataTable(_AssetsRepository.GetAll().OrderByDescending(a => a.CREATEDATE).AsNoTracking())); }