/// <summary> /// 自动盘点: /// • 通过当前【设备编码/id】从表格 【设备管理】(Equipment)中查询获取设备的’自动盘点计划’(InventoryPlanId)。 /// • 通过当前【id】(InventoryPlan.id=Equipment.InventoryPlanId)从表格【盘点计划管理理】(InventoryPlan)中查询获取相关盘点信息。 /// </summary> /// <param name="equipmentNameOrId"></param> /// <returns></returns> public BaseData <InventoryPlan> GetInventoryPlanByEquipmnetNameOrId(string equipmentNameOrId) { //根据设备编码或ID获取设备信息 var equipment = GetEquipmentByEquipmentNameOrId(equipmentNameOrId); //校验是否含有数据,如果含有数据,进行后续操作 HttpHelper.GetInstance().ResultCheck(equipment, out bool isSuccess); BaseData <InventoryPlan> plans = new BaseData <InventoryPlan>(); if (isSuccess) { //根据自动盘点计划Id查询盘点计划相关信息 if (null != equipment.body.objects[0].InventoryPlanId && equipment.body.objects[0].InventoryPlanId.Count > 0) { plans = HttpHelper.GetInstance().Get <InventoryPlan>(new QueryParam { @in = { field = "id", in_list = BllHelper.ParamUrlEncode(equipment.body.objects[0].InventoryPlanId) } }); } //校验是否含有数据,如果含有数据,拼接具体字段 plans = HttpHelper.GetInstance().ResultCheck(plans, out bool isSuccess2); } else { plans.code = equipment.code; plans.message = equipment.message; } return(plans); }
static void Main(string[] args) { BllHelper bll = new BllHelper(); //Expression<Func<T_User, bool>> expression = user => user.Nid > 1; //bll.DeleteUsers(expression); //bll.TestTransation(); //测试事务 //Expres.ExcExpression(); Log4Test.WriteLog(); Console.ReadKey(); }
///// <summary> ///// 指静脉识别 ///// </summary> ///// <param name="param">请求参数</param> ///// <returns></returns> //public BasePostData<string> VeinmatchLogin(string regfeature) //{ // //匿名类 // LogUtils.Debug("VeinmatchLogin: "******"account"></param> /// <returns></returns> public BaseData <string> GetUserToken(Account account) { //获取账户数据 BaseData <Account> baseDataAccount = HttpHelper.GetInstance().Get <Account>(new QueryParam { view_filter = { filter = { logical_relation = "1 AND 2", expressions = { new QueryParam.Expressions { field = "Phone", @operator = "CONTAINS", operands = { $"'{ HttpUtility.UrlEncode(account.Phone) }'" } }, new QueryParam.Expressions { field = "Password", @operator = "==", operands = { $"'{ BllHelper.EncodeBase64Str(account.Password) }'" } } } } } }); //根据账户获取用户数据 BaseData <User> baseDataUser = HttpHelper.GetInstance().ResultCheck((HttpHelper hh) => { return(hh.Get <User>(new QueryParam { @in = { field = "MobilePhone", in_list = { HttpUtility.UrlEncode(baseDataAccount.body.objects[0].Phone) } } })); }, baseDataAccount); //根据用户获取token return(HttpHelper.GetInstance().ResultCheck((HttpHelper hh) => { return hh.Get <string>(HttpHelper.GetCommonQueryUrl(HttpConstant.TokenUrl, new TokenQueryParam { user_id = baseDataUser.body.objects[0].id })); }, baseDataUser)); }
public BaseData <CommodityCode> GetQualityStatus(BaseData <CommodityCode> bdCommodityCode, out bool isSuccess) { isSuccess = false; //检查参数是否正确 if (null == bdCommodityCode.body.objects || bdCommodityCode.body.objects.Count <= 0) { bdCommodityCode.code = (int)ResultCode.Parameter_Exception; bdCommodityCode.message = ResultCode.Parameter_Exception.ToString(); return(bdCommodityCode); } //通过【商品码】从表格【商品库存管理】中查询该条库存的id(CommodityInventoryDetailId)。 var commodityCodeIds = bdCommodityCode.body.objects.Select(it => it.id).Distinct().ToList(); var commodityInventoryDetails = HttpHelper.GetInstance().Get <CommodityInventoryDetail>(new QueryParam { @in = { field = "CommodityCodeId", in_list = BllHelper.ParamUrlEncode(commodityCodeIds) } }); HttpHelper.GetInstance().ResultCheck(commodityInventoryDetails, out bool isSuccess1); if (!isSuccess1) { bdCommodityCode.code = (int)ResultCode.Result_Exception; bdCommodityCode.message = ResultCode.Result_Exception.ToString(); return(bdCommodityCode); } bdCommodityCode.body.objects.ForEach(it => { it.QualityStatus = commodityInventoryDetails.body.objects.Where(cid => cid.CommodityCodeId == it.id).First().QualityStatus; it.InventoryStatus = commodityInventoryDetails.body.objects.Where(cid => cid.CommodityCodeId == it.id).First().Status; }); isSuccess = true; return(bdCommodityCode); }
public BaseData <CommodityCode> GetExpirationAndManufactor(BaseData <CommodityCode> bdCommodityCode, out bool isSuccess) { isSuccess = false; //检查参数是否正确 if (null == bdCommodityCode.body.objects || bdCommodityCode.body.objects.Count <= 0) { bdCommodityCode.code = (int)ResultCode.Parameter_Exception; bdCommodityCode.message = ResultCode.Parameter_Exception.ToString(); return(bdCommodityCode); } //通过【商品码】从表格【商品库存管理】中查询该条库存的id(CommodityInventoryDetailId)。 var commodityCodeIds = bdCommodityCode.body.objects.Select(it => it.id).Distinct().ToList(); var commodityInventoryDetails = HttpHelper.GetInstance().Get <CommodityInventoryDetail>(new QueryParam { @in = { field = "CommodityCodeId", in_list = BllHelper.ParamUrlEncode(commodityCodeIds) } }); HttpHelper.GetInstance().ResultCheck(commodityInventoryDetails, out bool isSuccess1); if (!isSuccess1) { bdCommodityCode.code = (int)ResultCode.Result_Exception; bdCommodityCode.message = ResultCode.Result_Exception.ToString(); return(bdCommodityCode); } bdCommodityCode.body.objects.ForEach(it => { it.CommodityInventoryDetailId = commodityInventoryDetails.body.objects.Where(cid => cid.CommodityCodeId == it.id).First().id; }); //通过【关联商品】(CommodityInventoryDetailId)从表格【商品库存货品明细】中获取相关货品列表。 var CommodityInventoryDetailIds = bdCommodityCode.body.objects.Select(it => it.CommodityInventoryDetailId).Distinct().ToList(); var commodityInventoryGoods = HttpHelper.GetInstance().Get <CommodityInventoryGoods>(new QueryParam { @in = { field = "CommodityInventoryDetailId", in_list = BllHelper.ParamUrlEncode(CommodityInventoryDetailIds) } }); HttpHelper.GetInstance().ResultCheck(commodityInventoryGoods, out bool isSuccess2); if (!isSuccess2) { bdCommodityCode.code = (int)ResultCode.Result_Exception; bdCommodityCode.message = ResultCode.Result_Exception.ToString(); return(bdCommodityCode); } bdCommodityCode.body.objects.ForEach(it => { //在CommodityInventoryGoods表中,如果一个CommodityInventoryDetailId 对应有多条记录,说明一个商品对应了多个货品,那就不属于单品,智能柜不用显示 if (commodityInventoryGoods.body.objects.Where(cig => cig.CommodityInventoryDetailId == it.CommodityInventoryDetailId).Count() == 1) { it.BatchNumberId = commodityInventoryGoods.body.objects.Where(cid => cid.CommodityInventoryDetailId == it.CommodityInventoryDetailId).First().BatchNumberId; it.HospitalGoodsId = commodityInventoryGoods.body.objects.Where(cid => cid.CommodityInventoryDetailId == it.CommodityInventoryDetailId).First().HospitalGoodsId; } }); //通过【生产批号】(CommodityInventoryGoods.BatchNumberId)从表格【生产批号管理详情】中获得相关批号信息。 var batchNumberIds = bdCommodityCode.body.objects.Select(it => it.BatchNumberId).Distinct().ToList(); var batchNumber = HttpHelper.GetInstance().Get <BatchNumber>(new QueryParam { @in = { field = "id", in_list = BllHelper.ParamUrlEncode(batchNumberIds) } }); HttpHelper.GetInstance().ResultCheck(batchNumber, out bool isSuccess3); if (!isSuccess3) { bdCommodityCode.code = (int)ResultCode.Result_Exception; bdCommodityCode.message = ResultCode.Result_Exception.ToString(); return(bdCommodityCode); } bdCommodityCode.body.objects.ForEach(it => { if (it.BatchNumberId != null) { it.ExpirationDate = Convert.ToDateTime(batchNumber.body.objects.Where(bn => bn.id == it.BatchNumberId).First().ExpirationDate); } }); //通过【货品名称】(HospitalGoodsId)从表格【医院货品管理详情】中获得厂家名称。 var hospitalGoodsIds = bdCommodityCode.body.objects.Select(it => it.HospitalGoodsId).Distinct().ToList(); var hospitalGoods = HttpHelper.GetInstance().Get <HospitalGoods>(new QueryParam { @in = { field = "id", in_list = BllHelper.ParamUrlEncode(hospitalGoodsIds) } }); HttpHelper.GetInstance().ResultCheck(hospitalGoods, out bool isSuccess4); if (!isSuccess4) { bdCommodityCode.code = (int)ResultCode.Result_Exception; bdCommodityCode.message = ResultCode.Result_Exception.ToString(); return(bdCommodityCode); } bdCommodityCode.body.objects.ForEach(it => { if (it.HospitalGoodsId != null) { it.ManufactorName = hospitalGoods.body.objects.Where(hg => hg.id == it.HospitalGoodsId).First().ManufactorName; } }); isSuccess = true; return(bdCommodityCode); }
/// <summary> /// 【智能柜】 自动盘点更新盘点单管理和其商品明细 ,post请求为admintoken /// </summary> /// <param name="orders"></param> /// <returns></returns> public BasePostData <InventoryDetail> CreateInventoryOrderAndDetail(List <CommodityCode> commodityCodes) { BasePostData <InventoryDetail> inventoryDetailRet; if (null == commodityCodes || commodityCodes.Count <= 0) { inventoryDetailRet = new BasePostData <InventoryDetail>() { code = (int)ResultCode.Parameter_Exception, message = ResultCode.Parameter_Exception.ToString() }; return(inventoryDetailRet); } //创建盘点任务单 var inventoryTasks = HttpHelper.GetInstance().PostByAdminToken(new PostParam <InventoryTask>() { objects = { new InventoryTask { Status = InventoryTaskStatus.待确认.ToString() } } }); HttpHelper.GetInstance().ResultCheck(inventoryTasks, out bool isSuccess); if (isSuccess) { string now = GetDateTimeNow(); List <InventoryOrder> inventoryOrderList = new List <InventoryOrder>(); //分柜创建盘点任务 commodityCodes.Select(it => it.GoodsLocationId).Distinct().ToList().ForEach(goodsLocationId => { inventoryOrderList.Add(new InventoryOrder { ConfirmDate = now, InventoryTaskId = inventoryTasks.body[0].id, Status = InventoryOrderStatus.待盘点.ToString(), //创建盘点单状态为[待盘点] //TODO: 需要当前设备id,货位id和库房id GoodsLocationId = goodsLocationId, EquipmentId = ApplicationState.GetEquipId(), StoreHouseId = ApplicationState.GetHouseId(), Type = "自动创建" }); }); //创建盘点单 var inventoryOrders = HttpHelper.GetInstance().PostByAdminToken(new PostParam <InventoryOrder>() { objects = inventoryOrderList }); inventoryDetailRet = HttpHelper.GetInstance().ResultCheck((HttpHelper hh) => { BaseData <CommodityInventoryDetail> CommodityInventoryDetails = null; if (commodityCodes.Count > 0) { var commodityCodeIds = commodityCodes.Select(it => it.id).Distinct().ToList(); CommodityInventoryDetails = hh.Get <CommodityInventoryDetail>(new QueryParam { @in = { field = "CommodityCodeId", in_list = BllHelper.ParamUrlEncode(commodityCodeIds) } }); } if (CommodityInventoryDetails != null) { hh.ResultCheck(CommodityInventoryDetails, out bool isSuccessq); if (isSuccessq) { commodityCodes.ForEach(it => { it.CommodityInventoryId = CommodityInventoryDetails.body.objects.Where(cit => cit.CommodityCodeId == it.id).First().id; }); } } List <InventoryDetail> inventoryDetailList = new List <InventoryDetail>(); commodityCodes.ForEach(it => { inventoryDetailList.Add(new InventoryDetail { CommodityInventoryId = it.CommodityInventoryId, InventoryOrderId = inventoryOrders.body.Where(iit => iit.GoodsLocationId == it.GoodsLocationId).Select(iit => iit.id).First(), CommodityCodeId = it.id }); }); //创建盘名单明细列表 return(hh.PostByAdminToken(new PostParam <InventoryDetail>() { objects = inventoryDetailList })); }, inventoryOrders); //更新盘点单状态 if (inventoryDetailRet != null) { var orderIds = inventoryDetailRet.body.Select(it => it.InventoryOrderId).Distinct().ToList(); orderIds.ForEach(id => { var temp = inventoryOrders.body.Where(it => it.id.Equals(id)).First(); //temp.Status = InventoryOrderStatus.已完成.ToString(); //执行更新操作,异常状态记录日志,详情见方法体内部 UpdateInventoryOrderStatus(temp); }); } } else { inventoryDetailRet = new BasePostData <InventoryDetail>() { code = (int)ResultCode.Result_Exception, message = ResultCode.Result_Exception.ToString() }; } return(inventoryDetailRet); }
/// <summary> /// 【手动盘点】 逐一创建【盘点商品明细】。 /// InventoryDetail所需字段: /// CommodityInventoryId 商品编码 /// InventoryOrderId 关联盘点单 /// Statis 质量状态 【正常 损坏】 /// Type 类型 【账面存在 盘点缺失 盘点新增】 /// </summary> /// <param name="details"></param> /// <returns></returns> public BasePostData <InventoryDetail> CreateInventoryDetail(List <CommodityCode> commodityCodes, string inventoryOrderId) { if (null == commodityCodes || commodityCodes.Count <= 0) { return(new BasePostData <InventoryDetail>() { code = (int)ResultCode.Parameter_Exception, message = ResultCode.Parameter_Exception.ToString() }); } BaseData <CommodityInventoryDetail> CommodityInventoryDetails = null; if (commodityCodes.Count > 0) { var commodityCodeIds = commodityCodes.Select(it => it.id).Distinct().ToList(); CommodityInventoryDetails = HttpHelper.GetInstance().Get <CommodityInventoryDetail>(new QueryParam { @in = { field = "CommodityCodeId", in_list = BllHelper.ParamUrlEncode(commodityCodeIds) } }); } if (CommodityInventoryDetails == null) { return(new BasePostData <InventoryDetail>() { code = (int)ResultCode.Business_Exception, message = ResultCode.Business_Exception.ToString() }); } else { HttpHelper.GetInstance().ResultCheck(CommodityInventoryDetails, out bool isSuccess); if (isSuccess) { commodityCodes.ForEach(it => { it.CommodityInventoryId = CommodityInventoryDetails.body.objects.Where(cit => cit.CommodityCodeId == it.id).First().id; }); } } List <InventoryDetail> inventoryDetailList = new List <InventoryDetail>(); commodityCodes.ForEach(it => { inventoryDetailList.Add(new InventoryDetail { CommodityInventoryId = it.CommodityInventoryId, InventoryOrderId = inventoryOrderId, CommodityCodeId = it.id, Status = it.QStatus }); }); return(HttpHelper.GetInstance().Post(new PostParam <InventoryDetail>() { objects = inventoryDetailList })); }