Beispiel #1
0
        /// <summary>
        /// 往实例文档表中添加数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        //public BaseResult AddInstance_Document(T_INSTANCE_DOCUMENT info, enum_DocumentType t)
        //{
        //    BaseResult br = new BaseResult() { Succeeded = true, Errors = new List<string>() };
        //    using (BaseDB dbHelper = new OmpdDBHelper())
        //    {
        //        try
        //        {
        //            Dictionary<string, object> dic = BaseDB.EntityToDictionary(info);
        //            if (info.INSTANCE_DOCUMENT_ID > 0)
        //            {
        //                dbHelper.ExecuteNonQueryProc("pkg_redas_instance_document.sp_instance_document_modify", dic);
        //                br.ResultId = info.INSTANCE_DOCUMENT_ID;
        //            }
        //            else
        //            {

        //                dbHelper.ExecuteNonQueryProc("pkg_redas_instance_document.sp_instance_document_add", dic);
        //                decimal id = Convert.ToDecimal(dic["O_INSTANCE_DOCUMENT_ID"]);
        //                br.ResultId = id;
        //                //更改项目的实例ID
        //                if (info.Project_ID > 0)
        //                {
        //                    UpdateProjectInstanceDocumentID(info.Project_ID, id, t);
        //                }
        //                if (info.Object_ID > 0)
        //                {
        //                    UpdateObjectInstanceDocumentID(info.Object_ID, id, t);
        //                }
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            br.Succeeded = false;
        //            br.Errors.Add("添加不成功");
        //            throw;
        //        }
        //        return br;
        //    }
        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <param name="t">1:预估函 2:报告</param>
        /// <param name="isSingleObject">是否是单标的物</param>
        /// <param name="isDownLoadSort">是否是多标的物下载操作</param>
        /// <returns></returns>
        public BaseResult AddInstance_Document(T_INSTANCE_DOCUMENT info, EntrustItem t, bool isSingleObject, bool isDownLoadSort)
        {
            BaseResult br = new BaseResult()
            {
                Succeeded = true, Errors = new List <string>()
            };

            using (BaseDB dbHelper = new OmpdDBHelper())
            {
                try
                {
                    Dictionary <string, object> dic = BaseDB.EntityToDictionary(info);
                    if (info.INSTANCE_DOCUMENT_ID > 0)
                    {
                        dbHelper.ExecuteNonQueryProc("pkg_redas_instance_document.sp_instance_document_modify", dic);
                        br.ResultId = info.INSTANCE_DOCUMENT_ID;
                    }
                    else
                    {
                        dbHelper.ExecuteNonQueryProc("pkg_redas_instance_document.sp_instance_document_add", dic);
                        decimal id = Convert.ToDecimal(dic["O_INSTANCE_DOCUMENT_ID"]);
                        br.ResultId = id;
                        //更改项目的实例ID 多标的物的实例保存  只要更新object表InstanceID,多标的物的下载保存  需要更新projectID
                        if (!isSingleObject)
                        {                            //UpdateProjectInstanceDocumentID(info.Project_ID, id, t);
                            if (isDownLoadSort)
                            {
                                UpdateInstanceDocumentID(0, info.Project_ID, id, t);
                            }
                            else
                            {
                                UpdateInstanceDocumentID(info.Object_ID, 0, id, t);
                            }
                        }
                        else  //单标的物的预估函即要更新object表InstanceID 也要更新project表的InstanceID
                        {
                            //更改object表
                            UpdateInstanceDocumentID(info.Object_ID, 0, id, t);
                            //更改project表
                            UpdateInstanceDocumentID(0, info.Project_ID, id, t);
                        }
                    }
                }
                catch (Exception ex)
                {
                    br.Succeeded = false;
                    br.Errors.Add("添加不成功");
                    throw;
                }
                return(br);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更改估价对象表的ReportFileID
        /// </summary>
        /// <param name="objectId"></param>
        /// <param name="report_file_id"></param>
        public void UpdateReportFileID(decimal objectId, decimal report_file_id, EntrustItem t)
        {
            BaseResult br = new BaseResult()
            {
                Succeeded = true, Errors = new List <string>()
            };

            using (BaseDB dbHelper = new RedasDBHelper())
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("i_object_id", objectId);
                dic.Add("i_report_file_id", report_file_id);
                dic.Add("i_type", (int)t);
                dbHelper.ExecuteNonQueryProc("PKG_OBJECT.sp_ReportFileID_update", dic);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 根据估价对象ID获得实例信息
        /// </summary>
        /// <param name="objectId"></param>
        /// <param name="templateType"></param>
        /// <returns></returns>
        public T_INSTANCE_DOCUMENT GetInstanceDocumentGetByObject(decimal objectId, EntrustItem businessType)
        {
            T_INSTANCE_DOCUMENT result = null;

            using (BaseDB dbHelper = new OmpdDBHelper())
            {
                try
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("i_OBJECT_ID", objectId);
                    dic.Add("i_businessType", (int)businessType);
                    List <T_INSTANCE_DOCUMENT> lst = dbHelper.ExecuteListProc <T_INSTANCE_DOCUMENT>("pkg_redas_instance_document.sp_instanceDocumentGetByObject", dic);
                    result = lst[0];
                }
                catch
                {
                }
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        ///  保存报告字段信息后,需要更新估价对象的报告实例ID
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private void UpdateProjectInstanceDocumentID(decimal projectId, decimal instance_Document_ID, EntrustItem t)
        {
            BaseResult br = new BaseResult()
            {
                Succeeded = true, Errors = new List <string>()
            };

            using (BaseDB dbHelper = new RedasDBHelper())
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("i_project_id", projectId);
                dic.Add("i_instanceDocument_id", instance_Document_ID);
                dic.Add("i_type", (int)t);
                dbHelper.ExecuteNonQueryProc("pkg_project.sp_InstanceDocumentID_update", dic);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 根据估价对象ID获得实例信息
        /// </summary>
        /// <param name="objectId"></param>
        /// <param name="templateType"></param>
        /// <returns></returns>
        public List <_ChangeSortModel> GetObjectInstanceByProjectId(decimal projectId, EntrustItem businessType, decimal customerId)
        {
            List <_ChangeSortModel> result = new List <_ChangeSortModel>();

            using (BaseDB dbHelper = new OmpdDBHelper())
            {
                try
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("i_project_id", projectId);
                    dic.Add("i_businessType", (int)businessType);
                    List <_ObjectInstance> lst = dbHelper.ExecuteListProc <_ObjectInstance>("pkg_redas_instance_document.sp_ObjectInstance_Get", dic);
                    string prjStructure        = dic["O_PRJ_STRUCTURE"].ToString();

                    //获得构件的排序
                    IList <Document_structureModel> lstStructure        = new Document_structureLogic().GetByCustomer(customerId, 0, 0);
                    Dictionary <decimal, decimal>   dicStructureAndSort = new Dictionary <decimal, decimal>(); //优先考虑项目是否已经保存排序,为保存则读取构件中的排序
                    List <_ProjectStructrue>        lstPrjStructure     = new List <_ProjectStructrue>();

                    //估价对象是否更换模板
                    bool isChangeMotherSet = false;
                    if (!string.IsNullOrEmpty(prjStructure))
                    {
                        lstPrjStructure = JsonTools.JsonToObject <List <_ProjectStructrue> >(prjStructure);
                        //如果与数据库的模板不匹配  表示已更换模板,所以排序显示的是构件表中的排序 (多标的物)
                        foreach (var info in lst)
                        {
                            //info.MOTHER_SET_ID
                            if (lstPrjStructure.Where(p => p.MotherSetId == info.MOTHER_SET_ID).Count() <= 0)
                            {
                                isChangeMotherSet = true;
                                break;
                            }
                        }
                    }
                    if (isChangeMotherSet || prjStructure == "")
                    {
                        foreach (var info in lstStructure)
                        {
                            dicStructureAndSort.Add(info.STRUCTURE_ID, info.SORT_NO);
                        }
                    }
                    var sort = 0;
                    foreach (var info in lst)
                    {
                        sort++;
                        //实例中的所有构件
                        Dictionary <BlockType, List <_DocStructrue> > structureCofig = GetStructureDictionary(info.DOCUMENT_STRUCTURE);
                        foreach (var dicConfig in structureCofig)
                        {
                            foreach (var structure in dicConfig.Value)
                            {
                                _ChangeSortModel model = new _ChangeSortModel();
                                model.Object_Name   = info.OBJECT_NAME;
                                model.StructureName = structure.Name;
                                model.StructureType = ((int)dicConfig.Key).ToString();
                                model.SturctureId   = structure.Key;
                                model.Type          = structure.Type;
                                model.Sort          = 0;
                                //单标的物就按数据库中的顺序来
                                if (lst.Count == 1)
                                {
                                    model.Sort = sort;
                                }
                                else
                                {
                                    //并没有更改模板 且 数据库中已保存排序
                                    if (!isChangeMotherSet && lstPrjStructure.Count > 0)
                                    {
                                        for (var i = 0; i < lstPrjStructure.Count(); i++)
                                        {
                                            if (lstPrjStructure[i].Key == structure.Key && lstPrjStructure[i].InstanceId == info.INSTANCE_DOCUMENT_ID)
                                            {
                                                model.Sort = i;
                                                break;
                                            }
                                        }
                                    }
                                    else if (model.Type == "Config") //只有用户上传的构件才有排序
                                    {
                                        model.Sort = dicStructureAndSort[model.SturctureId];
                                    }
                                }
                                model.Instance_document_id = info.INSTANCE_DOCUMENT_ID;
                                model.MotherSetId          = info.MOTHER_SET_ID;
                                result.Add(model);
                            }
                        }
                    }

                    result = result.OrderBy(p => p.StructureType).ThenBy(p => p.Type).ThenBy(p => p.Sort).ToList();
                }
                catch
                {
                }
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 创建DocMaster的实例
        /// </summary>
        /// <param name="masterID"></param>
        /// <param name="structureIds"></param>
        /// <returns></returns>
        public DocMaster CreateDocMaster(decimal masterID, decimal objectID, string jsonStructure, decimal instanceDocumentID, int currentUser, int customer_id, bool isBuildDoc, ref string error, bool?isReduction, EntrustItem?businessType, int?objectIndex)
        {
            string returnJSON = "";
            bool   isSearch   = true;
            //查询数据库是否已保存示例
            //isReduction为空的情况下是下载   1:预估函重新获取的时候,不需要传值;   2:报告 有实例的情况下:如果重新获取,即要拿预估函的信息;非重新获取,即拿本报告的
            //                                                                               无实例的情况下:拿预估函的实例
            EntrustItem estimateType = EntrustItem.Estimate;

            if (businessType == EntrustItem.Estimate)
            {
                if (isReduction != null && Convert.ToBoolean(isReduction))
                {
                    isSearch = false;  //不需要查询
                }
            }
            else if (businessType == EntrustItem.ValuationReport)
            {
                estimateType = EntrustItem.Estimate;
                if (instanceDocumentID > 0 && (isReduction == null || !Convert.ToBoolean(isReduction)))
                {
                    estimateType = EntrustItem.ValuationReport;
                }
            }

            if (isSearch)
            {
                T_INSTANCE_DOCUMENT instanceInfo = GetInstanceDocumentGetByObject(objectID, estimateType);
                if (instanceInfo != null && instanceInfo.MANUAL_EDITING_RETURN != "")
                {
                    returnJSON = instanceInfo.MANUAL_EDITING_RETURN;
                }
            }
            string conCode = "", buildingCode = "", houseCode = "", unitCode = "";
            var    formView = new FormLogic().GetFormDataByObjectId(Convert.ToInt32(objectID), 1);

            if (formView.LABLELIST != null)
            {
                List <Redas.Entities.Ompd.FormLabelDTO> lstLabel = formView.LABLELIST.ToList();

                //查询对应的楼盘,楼栋,房号的code
                conCode      = GetValFormList(lstLabel, "CONSTRUCTION_CODE");
                buildingCode = GetValFormList(lstLabel, "BUILDING_CODE");
                houseCode    = GetValFormList(lstLabel, "HOUSE_CODE");
                unitCode     = GetValFormList(lstLabel, "UNIT_CODE");
            }


            try
            {
                Dictionary <string, string> inputParams = new Dictionary <string, string>();
                inputParams.Add("ConstructionCode", conCode == null ? "" : conCode);
                inputParams.Add("BuildingCode", buildingCode == null ? "" : buildingCode);
                inputParams.Add("HouseCode", houseCode == null ? "" : houseCode);
                inputParams.Add("UnitCode", unitCode == null ? "" : unitCode);
                inputParams.Add("ObjectType", formView.OBJECT_TYPE_ID.ToString());
                inputParams.Add("CurrentUser", currentUser.ToString());
                inputParams.Add("CustomerID", customer_id.ToString());
                inputParams.Add("标的物顺序", objectIndex.ToString());
                //IsReduction 重新获取时 预估函:不需要查预估函   报告:需要查预估
                inputParams.Add("IsGetEstimate", isSearch.ToString());
                DocMaster docmaster = new DocMaster(masterID, objectID, returnJSON, jsonStructure, GetValue, inputParams, isBuildDoc);
                return(docmaster);
            }
            catch (Exception ex)
            {
                //throw ex;
                error = ex.Message;
                return(null);
            }
        }