Ejemplo n.º 1
0
        /// <summary>
        /// 获取工作流规则的各种定义信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <List <WorkflowConditionParaDto> > GetWorkflowFormByObject(DicEnum.WORKFLOW_OBJECT obj, long userId)
        {
            List <List <WorkflowConditionParaDto> > parasList = new List <List <WorkflowConditionParaDto> >();
            QueryCommonBLL queryBll  = new QueryCommonBLL();
            var            groupList = queryBll.GetQueryGroup((int)obj);
            List <string>  types     = new List <string> {
                "事件", "条件", "更新", "其他操作", "通知", "备注"
            };
            var queryParaDal = new DAL.d_query_para_dal();

            foreach (var tp in types)
            {
                if (groupList.Exists(_ => tp.Equals(_.name)))
                {
                    var grp = groupList.Find(_ => tp.Equals(_.name));
                    //parasList.Add(queryBll.GetConditionParaVisiable(userId, grp.id));

                    string sql   = $"select id,data_type_id as data_type,default_value as defaultValue,col_name,col_comment as description,ref_sql,ref_url,operator_type_id from d_query_para where query_para_group_id={grp.id} and is_visible=1 ";
                    var    paras = queryParaDal.FindListBySql <WorkflowConditionParaDto>(sql);
                    foreach (var dto in paras)
                    {
                        if (dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.DROPDOWN ||
                            dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.MULTI_DROPDOWN ||
                            dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.DYNAMIC)
                        {
                            var dt = queryParaDal.ExecuteDataTable(dto.ref_sql);
                            if (dt != null)
                            {
                                dto.values = new List <DictionaryEntryDto>();
                                foreach (System.Data.DataRow row in dt.Rows)
                                {
                                    dto.values.Add(new DictionaryEntryDto(row[0].ToString(), row[1].ToString()));
                                }
                            }
                        }
                    }

                    parasList.Add(paras);
                }
                else
                {
                    parasList.Add(null);
                }
            }
            return(parasList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取工作流规则的条件定义
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <List <WorkflowConditionParaDto> > GetWorkflowFormConditionByObject(DicEnum.WORKFLOW_OBJECT obj, long userId)
        {
            List <List <WorkflowConditionParaDto> > parasList = new List <List <WorkflowConditionParaDto> >();
            QueryCommonBLL queryBll  = new QueryCommonBLL();
            var            groupList = queryBll.GetQueryGroup((int)obj);
            var            grp       = groupList.Find(_ => "条件".Equals(_.name));
            string         sql       = $"select id,data_type_id as data_type,default_value as defaultValue,col_name,col_comment as description,ref_sql,ref_url,operator_type_id,(select name from d_general where id=operator_type_id) as operatorName from d_query_para where query_para_group_id={grp.id} and is_visible=1 and operator_type_id is not null";
            var            paras     = new DAL.d_query_para_dal().FindListBySql <WorkflowConditionParaDto>(sql);

            sql = $"select distinct(col_comment) from d_query_para where query_para_group_id={grp.id} and is_visible=1 and operator_type_id is not null";
            var cdts = new DAL.d_query_para_dal().FindListBySql <string>(sql);

            foreach (var cdt in cdts)
            {
                var dtos = (from prm in paras where cdt.Equals(prm.description) select prm).ToList();
                foreach (var dto in dtos)
                {
                    if (dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.DROPDOWN ||
                        dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.MULTI_DROPDOWN ||
                        dto.data_type == (int)DicEnum.QUERY_PARA_TYPE.DYNAMIC)
                    {
                        var dt = new DAL.d_query_para_dal().ExecuteDataTable(dto.ref_sql);
                        if (dt != null)
                        {
                            dto.values = new List <DictionaryEntryDto>();
                            foreach (System.Data.DataRow row in dt.Rows)
                            {
                                dto.values.Add(new DictionaryEntryDto(row[0].ToString(), row[1].ToString()));
                            }
                        }
                    }
                }
                parasList.Add(dtos);
            }

            return(parasList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据库存产品id列表获取采购订单的采购项信息
        /// </summary>
        /// <param name="pdtIds"></param>
        /// <returns></returns>
        public PurchaseOrderItemManageDto InitPurchaseOrderItems(string pdtIds, out long vendorId)
        {
            vendorId = 0;
            PurchaseOrderItemManageDto dto = new PurchaseOrderItemManageDto();
            string sql = $"select product_id,warehouse_id,(select name from ivt_product where id=product_id) as product,(select unit_cost from ivt_product where id=product_id) as unit_cost,(select name from ivt_warehouse where id=warehouse_id) as locationName,(quantity_maximum-quantity) as quantity from ivt_warehouse_product where id in({pdtIds})";

            dto.items = dal.FindListBySql <PurchaseItemDto>(sql);
            for (var i = 0; i < dto.items.Count; ++i)
            {
                dto.items[i].id = dto.index++;
                if (dto.items[i].quantity < 0)
                {
                    dto.items[i].quantity = 0;
                }
            }
            if (dto.items.Count == 0)
            {
                sql       = $"select id,id as costId,product_id,(select id from ivt_warehouse where is_default=1 and delete_time=0) as warehouse_id,unit_cost,(select name from ivt_product where id=product_id) as product,(select name from ivt_warehouse where is_default=1 and delete_time=0) as locationName from ctt_contract_cost where id in({pdtIds})";
                dto.items = dal.FindListBySql <PurchaseItemDto>(sql);
                if (dto.items.Count == 0)
                {
                    return(dto);
                }

                QueryCommonBLL queryBll  = new QueryCommonBLL();
                QueryParaDto   queryPara = new QueryParaDto();
                queryPara.query_params  = new List <Para>();
                queryPara.query_type_id = (long)QueryType.PurchaseFulfillment;
                queryPara.para_group_id = 156;
                queryPara.page          = 1;
                queryPara.page_size     = 500;
                QueryResultDto queryResult = queryBll.GetResult(0, queryPara);
                if (queryResult.count == 0)
                {
                    return(dto);
                }
                for (var i = 0; i < dto.items.Count; ++i)
                {
                    var find = queryResult.result.Find(_ => _["成本id"].ToString().Equals(dto.items[i].id.ToString()));
                    if (find == null)
                    {
                        continue;
                    }
                    dto.items[i].quantity     = (int)(string.IsNullOrEmpty(find["采购数量"].ToString()) ? 0 : decimal.Parse(find["采购数量"].ToString()));
                    dto.items[i].accountName  = find["销售订单"].ToString() + "(" + find["客户"].ToString() + ")";
                    dto.items[i].contractName = find["工单或项目或合同"].ToString();
                    dto.items[i].id           = dto.index++;
                }
            }

            string productIds = "";

            for (var i = 0; i < dto.items.Count; ++i)
            {
                productIds += dto.items[i].product_id + ",";
                long lctPdtId = dal.FindSignleBySql <long>($"select id from ivt_warehouse_product where product_id={dto.items[i].product_id} and warehouse_id={dto.items[i].warehouse_id}");
                var  lctPdt   = GetIvtProductEdit(lctPdtId);
                if (lctPdt != null)
                {
                    dto.items[i].ivtQuantity     = lctPdt.quantity;
                    dto.items[i].onOrder         = lctPdt.on_order;
                    dto.items[i].max             = lctPdt.quantity_maximum;
                    dto.items[i].min             = lctPdt.quantity_minimum;
                    dto.items[i].reserved_picked = lctPdt.reserved_picked;
                    dto.items[i].back_order      = lctPdt.back_order;
                    if (string.IsNullOrEmpty(lctPdt.reserved_picked))
                    {
                        dto.items[i].avaCnt = "";
                    }
                    else
                    {
                        dto.items[i].avaCnt = (lctPdt.quantity - int.Parse(lctPdt.reserved_picked)).ToString();
                    }
                }
            }

            // 获取采购项产品的默认供应商,如果只有一个默认供应商,则返回
            if (productIds != "")
            {
                productIds = productIds.Substring(0, productIds.Length - 1);
                var ids = dal.FindListBySql <long>($"select vendor_account_id from ivt_product_vendor where is_default=1 and product_id in({productIds})");
                if (ids != null && ids.Count == 1)
                {
                    vendorId = ids[0];
                }
            }

            return(dto);
        }