コード例 #1
0
ファイル: TestController.cs プロジェクト: kingshhh/fxtcode
        public ActionResult AllotFlowTest(AllotFlow allotFlow)
        {
            //名称管理器
            //var excelHelper = new ExcelHandle("E:\\TempletForTV.xlsx");
            //DataTable dt = excelHelper.ExcelToDataTable("周(List)", true);
            allotFlow.Remark = "太神奇了2";
            //_unitOfWork.AllotFlowRepository.Update(allotFlow);
            //_unitOfWork.Commit();

            //fluent api 关系配置
            AllotFlow unitOfWork = _unitOfWork.AllotFlowRepository.GetById(4923);

            //AllotSurvey allotSurvey = _unitOfWork.AllotSurveyRepository.GetBy(m => m.AllotId == 4925);
            //var a = allotSurvey.AllotFlow;

            unitOfWork.Project.ProjectName = "楼盘啊32";
            unitOfWork.Remark = "金地翠园32";
            _unitOfWork.Commit();
            //Project project = _unitOfWork.ProjectRepository.GetById(4954);
            return(Content("test"));
            //return View();
        }
コード例 #2
0
ファイル: AllotFlowService.cs プロジェクト: kingshhh/fxtcode
        /// <summary>
        /// 新增任务
        /// </summary>
        /// <param name="project">楼盘</param>
        /// <param name="developersCompany">开发商</param>
        /// <param name="managerCompany">物管公司</param>
        /// <returns>任务已存在返回任务状态,1.成功,0失败,-1未设置模板</returns>
        public ProjectAllotFlowSurveyDto AddAllot(Project project, string developersCompany, string managerCompany, string remark, int cityId, int fxtCompanyId, string userName, string userTrueName, int status)
        {
            ProjectAllotFlowSurveyDto dto = new ProjectAllotFlowSurveyDto();

            DateTime now = DateTime.Now;

            //模板
            var templet = _unitOfWork.TempletRepository.GetBy(m => m.FxtCompanyId == fxtCompanyId && m.DatType == SYSCodeManager.DATATYPECODE_1 && m.IsCurrent == true && m.Vaild == 1);

            if (templet == null)
            {
                dto.AllotState = -1;

                return(dto);
            }

            project.CityID       = cityId;
            project.Status       = status;
            project.FxtCompanyId = fxtCompanyId;
            project.CreateTime   = now;
            project.Creator      = userName;
            project.Valid        = 1;
            project.TempletId    = templet.TempletId;
            project = _unitOfWork.ProjectRepository.Insert(project);
            _unitOfWork.Commit();
            //任务
            var allot = new AllotFlow()
            {
                CityId             = project.CityID,
                CreateTime         = now,
                DatType            = SYSCodeManager.DATATYPECODE_1,
                FxtCompanyId       = project.FxtCompanyId.Value,
                UserName           = userName,
                UserTrueName       = userTrueName,
                StateCode          = status,
                DatId              = project.ProjectId,
                StateDate          = now,
                SurveyUserName     = status == SYSCodeManager.STATECODE_2 ? userName : "",
                SurveyUserTrueName = status == SYSCodeManager.STATECODE_2 ? userTrueName : ""
            };

            allot = _unitOfWork.AllotFlowRepository.Insert(allot);
            _unitOfWork.Commit();
            //任务记录
            var allotSurvey = new AllotSurvey()
            {
                AllotId      = allot.Id,
                CityId       = allot.CityId,
                FxtCompanyId = fxtCompanyId,
                CreateDate   = now,
                StateCode    = status,
                StateDate    = now,
                UserName     = userName,
                TrueName     = userTrueName,
                Remark       = remark
            };

            allotSurvey = _unitOfWork.AllotSurveyRepository.Insert(allotSurvey);
            //停车状况
            var parkingStatus = _unitOfWork.P_AppendageRepository.Get(m => m.AppendageCode == SYSCodeManager.APPENDAGECODE_14 && m.CityId == project.CityID && m.ProjectId == project.ProjectId).FirstOrDefault();

            if (parkingStatus != null)
            {
                parkingStatus.ClassCode = project.ParkingStatus;
                _unitOfWork.P_AppendageRepository.Update(parkingStatus);
            }
            else
            {
                parkingStatus               = new PAppendage();
                parkingStatus.ClassCode     = project.ParkingStatus;
                parkingStatus.AppendageCode = SYSCodeManager.APPENDAGECODE_14;
                parkingStatus.CityId        = project.CityID;
                parkingStatus.ProjectId     = project.ProjectId;
                parkingStatus.IsInner       = true;
                _unitOfWork.P_AppendageRepository.Insert(parkingStatus);
            }
            //开发商
            if (!string.IsNullOrEmpty(developersCompany))
            {
                var developcompany = _unitOfWork.P_CompanyRepository.Get(m => m.CompanyName == developersCompany && m.CompanyType == SYSCodeManager.COMPANYTYPECODE_1 &&
                                                                         m.ProjectId == project.ProjectId && m.CityId == project.CityID).FirstOrDefault();
                if (developcompany == null)
                {
                    developcompany             = new PCompany();
                    developcompany.CityId      = project.CityID;
                    developcompany.CompanyName = developersCompany;
                    developcompany.CompanyType = SYSCodeManager.COMPANYTYPECODE_1;
                    developcompany.ProjectId   = project.ProjectId;
                    _unitOfWork.P_CompanyRepository.Insert(developcompany);
                }
            }
            //物管公司
            if (!string.IsNullOrEmpty(managerCompany))
            {
                var managercompany = _unitOfWork.P_CompanyRepository.Get(m => m.CompanyName == managerCompany && m.CompanyType == SYSCodeManager.COMPANYTYPECODE_4 &&
                                                                         m.ProjectId == project.ProjectId && m.CityId == project.CityID).FirstOrDefault();
                if (managercompany == null)
                {
                    managercompany             = new PCompany();
                    managercompany.CityId      = project.CityID;
                    managercompany.CompanyName = managerCompany;
                    managercompany.CompanyType = SYSCodeManager.COMPANYTYPECODE_4;
                    managercompany.ProjectId   = project.ProjectId;
                    _unitOfWork.P_CompanyRepository.Insert(managercompany);
                }
            }

            dto.AllotId    = allot.Id;
            dto.ProjectId  = project.ProjectId;
            dto.AllotState = _unitOfWork.Commit() > 0 ? 1 : 0;
            return(dto);
        }
コード例 #3
0
ファイル: AllotFlowService.cs プロジェクト: kingshhh/fxtcode
        public int ImportToDataCenter(long allowId, int cityId, int companyId, string userName, string userTrueName, string signName, List <Apps> appList, out string message)
        {
            AllotFlow allot = _unitOfWork.AllotFlowRepository.GetById(allowId);

            if (allot == null || allot.StateCode != SYSCodeManager.STATECODE_8)
            {
                message = "入库失败:该任务不存在或者该任务状态不为审核通过";
                return(0);
            }
            if (allot.DatType == SYSCodeManager.DATATYPECODE_1)
            {
                //Project proj = _unitOfWork.ProjectRepository.GetBy(m => m.ProjectId == allot.DatId && m.CityID == cityId);

                //ProjectDto project = Mapper.Map<Project, ProjectDto>(proj);

                //List<PCompany> lnkpc = _unitOfWork.P_CompanyRepository.Get(m => m.ProjectId == allot.Project.ProjectId && m.CityId == cityId).ToList();

                //List<PAppendage> lnkpa = _unitOfWork.P_AppendageRepository.Get(m => m.ProjectId == allot.Project.ProjectId && m.CityId == cityId).ToList();

                //if (lnkpa != null && lnkpa.Count > 0)
                //{
                //    lnkpa = lnkpa.Select(m => new PAppendage()
                //    {
                //        Address = m.Address,
                //        AppendageCode = m.AppendageCode,
                //        Area = m.Area,
                //        CityId = m.CityId,
                //        ClassCode = m.ClassCode,
                //        Distance = m.Distance,
                //        Id = m.Id,
                //        IsInner = m.IsInner,
                //        P_AName = m.P_AName,
                //        ProjectId = m.ProjectId,
                //        Uid = m.Uid,
                //        X = m.X,
                //        Y = m.Y
                //    }).ToList();
                //}

                //var bList = _unitOfWork.BuildingRepository.Get(m => m.ProjectId == proj.ProjectId && m.CityID == cityId);
                //var hList = _unitOfWork.HouseDetailsRepository.Get();
                //List<HouseDetails> houseList = (from b in bList
                //                                join h in hList on b.BuildingId equals h.BuildingId
                //                                select h).ToList();
                //List<Building> buildingList = bList.ToList();

                List <Building> resultBuildings = new List <Building>();//返回的楼栋ids
                int             fxtprojectId    = DataCenterProjectApi.ImportProjectData(allot.Project, ref resultBuildings, userName, signName, appList, out message);
                if (fxtprojectId <= 0)
                {
                    message = "入库失败:导入楼盘信息异常";
                    return(0);
                }

                //_unitOfWork.ProjectRepository.Update(proj);
                //上传照片
                List <PPhoto> photoList = _unitOfWork.P_PhotoRepository.Get(m => m.ProjectId == allot.Project.ProjectId && m.CityId == cityId && m.FxtCompanyId == companyId).ToList();
                foreach (PPhoto pObj in photoList)
                {
                    //FileStream fStream = new FileStream(System.Web.HttpContext.Current.Server.MapPath(pObj.Path), FileMode.Open, FileAccess.Read);
                    var path = ConfigurationManager.AppSettings["OssDownload"] + pObj.Path;
                    using (WebClient client = new WebClient())
                    {
                        var data = client.DownloadData(path);
                        //BinaryReader bReader = new BinaryReader(fStream);//将文件了加载成二进制数据
                        //long length = bReader.BaseStream.Length;//当前文件的总大小
                        ////创建一个用于存储要上传文件内容的字节对象
                        //byte[] data = new byte[length];
                        ////将流中读取指定字节数加载到到字节对象data
                        //bReader.Read(data, 0, Convert.ToInt32(length));
                        pObj.PhotoTypeCode = pObj.PhotoTypeCode.HasValue ? pObj.PhotoTypeCode.Value : 0;
                        long fxtbuildingid = 0;
                        //楼栋图片
                        if (pObj.BuildingId.HasValue && pObj.BuildingId > 0)
                        {
                            var nowBuilding = resultBuildings.Where(m => m.BuildingId == pObj.BuildingId).FirstOrDefault();
                            if (nowBuilding != null)
                            {
                                fxtbuildingid = Convert.ToInt64(nowBuilding.FxtBuildingId);
                            }
                        }
                        if (DataCenterProjectApi.AddProjectPhoto(fxtprojectId, fxtbuildingid, cityId, pObj.PhotoTypeCode.Value, new FileInfo(System.Web.HttpContext.Current.Server.MapPath(pObj.Path)).Name, pObj.PhotoName, data, userName, signName, appList, out message) != 1)
                        {
                            message = "入库失败:上传楼盘照片失败(id:" + pObj.Id + ")";
                            return(0);
                        }
                    }
                }

                if (resultBuildings != null && resultBuildings.Count > 0)
                {
                    foreach (var item in resultBuildings)
                    {
                        var building = _unitOfWork.BuildingRepository.GetById(item.BuildingId);
                        if (building.FxtBuildingId != item.FxtBuildingId)
                        {
                            building.FxtBuildingId = item.FxtBuildingId;
                            _unitOfWork.BuildingRepository.Update(building);
                        }
                    }
                }

                //设置为已入库
                allot.Project.FxtProjectId = fxtprojectId;
                allot.Project.Status       = SYSCodeManager.STATECODE_10;
            }
            //设置为已入库
            allot.StateCode = SYSCodeManager.STATECODE_10;
            allot.StateDate = DateTime.Now;
            _unitOfWork.AllotFlowRepository.Update(allot);
            //记录日志
            _unitOfWork.AllotSurveyRepository.Insert(new AllotSurvey()
            {
                AllotId      = allowId,
                CityId       = cityId,
                FxtCompanyId = companyId,
                UserName     = userName,
                StateCode    = SYSCodeManager.STATECODE_10,
                StateDate    = DateTime.Now,
                CreateDate   = DateTime.Now,
                TrueName     = userTrueName,
                Remark       = "<span class=\"red\">入库</span>"
            });
            message = "入库成功!";
            return(_unitOfWork.Commit() > 0 ? 1 : 0);
        }
コード例 #4
0
        public int SetAllotProjectInfo(int allotId, string userName, string userTrueName, int fxtCompanyId, int cityId, ProjectDto projectDto, int isValid, out long returnAllotId, out int returnProjectId)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            log.Info("Stopwatch开始计时," + allotId);
            int housecount       = 0;
            int housedetailcount = 0;

            string message = string.Empty;

            returnAllotId   = allotId;
            returnProjectId = projectDto.ProjectId;
            DateTime  nowTime   = DateTime.Now;
            Project   project   = Mapper.Map <ProjectDto, Project>(projectDto);
            AllotFlow allotFlow = _unitOfWork.AllotFlowRepository.GetById(allotId);

            if (allotFlow == null)
            {
                return(-5);
            }
            //不是当前用户的任务
            if (allotFlow.SurveyUserName != userName.ToLower())
            {
                return(-2);
            }
            else if (allotFlow.StateCode != SYSCodeManager.STATECODE_4)
            {
                //不是查勘中任务
                return(-3);
            }

            //行政区 + 楼盘名称||已有的projectid||没有入库
            //var exists = _unitOfWork.ProjectRepository.Get(m =>
            //        (
            //            (m.ProjectName == project.ProjectName && m.AreaID == project.AreaID)
            //            && m.ProjectId != project.ProjectId
            //        )
            //        && m.Status != SYSCodeManager.STATECODE_10 && m.Valid == 1
            //    ).FirstOrDefault();
            //if (exists != null)
            //{
            //    message = "楼盘已存在";
            //    return -4;
            //}

            #region (Project更新值)
            if (isValid == 0 && !CheckProjectObj(project, out message))
            {
                return(0);
            }
            allotFlow.Project.EndDate        = projectDto.Enddate;
            allotFlow.Project.ManagerQuality = projectDto.Managerquality;
            allotFlow.Project.ParkingStatus  = projectDto.ParkingStatus;
            allotFlow.Project.PhotoCount     = projectDto.PhotoCount;
            allotFlow.Project.FxtProjectId   = projectDto.FxtProjectId;
            allotFlow.Project.ProjectName    = projectDto.ProjectName;
            allotFlow.Project.OtherName      = projectDto.OtherName;
            allotFlow.Project.CityID         = projectDto.CityID;
            allotFlow.Project.AreaID         = projectDto.AreaID;
            allotFlow.Project.SubAreaId      = projectDto.SubAreaId;
            allotFlow.Project.Address        = projectDto.Address;
            allotFlow.Project.PurposeCode    = projectDto.PurposeCode;
            allotFlow.Project.RightCode      = projectDto.RightCode;
            allotFlow.Project.Detail         = projectDto.Detail;
            allotFlow.Project.X             = projectDto.X;
            allotFlow.Project.Y             = projectDto.Y;
            allotFlow.Project.BuildingNum   = projectDto.BuildingNum;
            allotFlow.Project.TotalNum      = projectDto.Totalnum;
            allotFlow.Project.ParkingNumber = projectDto.Parkingnumber;
            allotFlow.Project.East          = projectDto.East;
            allotFlow.Project.West          = projectDto.West;
            allotFlow.Project.South         = projectDto.South;
            allotFlow.Project.North         = projectDto.North;
            allotFlow.Project.Status        = SYSCodeManager.STATECODE_4;
            allotFlow.Project.FxtCompanyId  = fxtCompanyId;
            allotFlow.Project.CityID        = cityId;
            allotFlow.Project.Valid         = 1;
            allotFlow.Project.SaveDateTime  = nowTime;  //最后修改时间
            allotFlow.Project.SaveUser      = userName; //修改人

            returnProjectId = allotFlow.Project.ProjectId;
            #endregion
            #region (停车状况)
            int        classcode  = project.ParkingStatus.HasValue ? project.ParkingStatus.Value : 0;
            PAppendage pAppendage = new PAppendage()
            {
                CityId        = cityId,
                ProjectId     = project.ProjectId,
                ClassCode     = classcode,
                AppendageCode = SYSCodeManager.APPENDAGECODE_14
            };

            PAppendage pAppend = _unitOfWork.P_AppendageRepository.GetBy(m => m.CityId == cityId && m.ProjectId == project.ProjectId && m.AppendageCode == SYSCodeManager.APPENDAGECODE_14);
            if (pAppend == null)
            {
                _unitOfWork.P_AppendageRepository.Insert(pAppendage);
            }
            else
            {
                pAppend.ClassCode = classcode;
                _unitOfWork.P_AppendageRepository.Update(pAppend);
            }

            #endregion
            #region (Project更新关联公司)
            //更新开发商
            if (!string.IsNullOrEmpty(projectDto.Developers))
            {
                var developers = _unitOfWork.P_CompanyRepository.GetBy(m => m.CityId == cityId && m.ProjectId == project.ProjectId && m.CompanyType == SYSCodeApi.COMPANYTYPECODE_1);
                if (developers == null)
                {
                    PCompany pcompany = new PCompany()
                    {
                        CityId      = cityId,
                        CompanyName = projectDto.Developers,
                        CompanyType = SYSCodeApi.COMPANYTYPECODE_1,
                        ProjectId   = project.ProjectId
                    };
                    _unitOfWork.P_CompanyRepository.Insert(pcompany);
                }
                else
                {
                    developers.CompanyName = projectDto.Developers;
                    _unitOfWork.P_CompanyRepository.Update(developers);
                }
            }
            else
            {
                _unitOfWork.P_CompanyRepository.Delete(m => m.CityId == cityId && m.ProjectId == project.ProjectId && m.CompanyType == SYSCodeApi.COMPANYTYPECODE_1);
            }

            //更新物业管理公司
            if (!string.IsNullOrEmpty(projectDto.ManagerCompany))
            {
                var managerCompany = _unitOfWork.P_CompanyRepository.GetBy(m => m.CityId == cityId && m.ProjectId == project.ProjectId && m.CompanyType == SYSCodeApi.COMPANYTYPECODE_4);
                if (managerCompany == null)
                {
                    PCompany pcompany = new PCompany()
                    {
                        CityId      = cityId,
                        CompanyName = projectDto.ManagerCompany,
                        CompanyType = SYSCodeApi.COMPANYTYPECODE_4,
                        ProjectId   = project.ProjectId
                    };
                    _unitOfWork.P_CompanyRepository.Insert(pcompany);
                }
                else
                {
                    managerCompany.CompanyName = projectDto.ManagerCompany;
                    _unitOfWork.P_CompanyRepository.Update(managerCompany);
                }
            }
            else
            {
                _unitOfWork.P_CompanyRepository.Delete(m => m.CityId == cityId && m.ProjectId == project.ProjectId && m.CompanyType == SYSCodeApi.COMPANYTYPECODE_4);
            }
            #endregion
            #region (Building更新值)
            if (projectDto.BuildingDtolist != null && projectDto.BuildingDtolist.Count > 0)
            {
                int bid = 0;
                foreach (var buildingDto in projectDto.BuildingDtolist)
                {
                    var       t    = false;
                    Stopwatch swbs = new Stopwatch();
                    swbs.Start();
                    //验证楼栋字段数据
                    if (!CheckBuildingObj(buildingDto, out message))
                    {
                        return(0);
                    }
                    //给building各属性赋值
                    Building building = Mapper.Map <BuildingDto, Building>(buildingDto);
                    building.Valid        = 1;
                    building.ProjectId    = project.ProjectId;
                    building.FxtCompanyId = allotFlow.FxtCompanyId;
                    building.CityID       = cityId;

                    //删除楼栋
                    if (buildingDto.Valid == 0)
                    {
                        var build = _unitOfWork.BuildingRepository.GetBy(m => m.AppId == building.AppId);
                        if (build != null)
                        {
                            _unitOfWork.HouseRepository.Delete(m => m.BuildingId == build.BuildingId);
                            _unitOfWork.HouseDetailsRepository.Delete(m => m.BuildingId == build.BuildingId);
                            _unitOfWork.BuildingRepository.Delete(m => m.AppId == building.AppId);
                        }
                    }
                    else
                    {
                        if (allotFlow.Project.Buildings == null)
                        {
                            allotFlow.Project.Buildings = new List <Building>();
                        }
                        Building eBuilding = allotFlow.Project.Buildings.Where(m => m.Valid == 1 && m.AppId == building.AppId).FirstOrDefault();

                        if (eBuilding == null)
                        {
                            building.Creator     = userName;
                            building.CreateTime  = nowTime;
                            eBuilding            = building;
                            eBuilding.BuildingId = bid++;
                            allotFlow.Project.Buildings.Add(eBuilding);
                        }
                        else
                        {
                            eBuilding.AppId           = buildingDto.AppId;
                            eBuilding.BuildDate       = buildingDto.BuildDate;
                            eBuilding.BuildingName    = buildingDto.BuildingName;
                            eBuilding.ElevatorRate    = buildingDto.ElevatorRate;
                            eBuilding.IsElevator      = buildingDto.IsElevator;
                            eBuilding.LocationCode    = buildingDto.LocationCode;
                            eBuilding.MaintenanceCode = buildingDto.MaintenanceCode;
                            eBuilding.OtherName       = buildingDto.OtherName;
                            eBuilding.PurposeCode     = buildingDto.PurposeCode;
                            eBuilding.Remark          = buildingDto.Remark;
                            eBuilding.StructureCode   = buildingDto.StructureCode;
                            eBuilding.TotalFloor      = buildingDto.TotalFloor;
                            eBuilding.UnitsNumber     = buildingDto.UnitsNumber;
                            eBuilding.X            = buildingDto.X;
                            eBuilding.Y            = buildingDto.Y;
                            eBuilding.SaveUser     = userName;
                            eBuilding.SaveDateTime = nowTime;
                        }

                        #region (设置house)
                        if (buildingDto.HouseDtolist != null && buildingDto.HouseDtolist.Count > 0)
                        {
                            foreach (var houseDto in buildingDto.HouseDtolist)
                            {
                                //验证房号字段数据
                                if (!CheckHouseObj(houseDto, out message))
                                {
                                    return(0);
                                }
                                houseDto.HouseId = 0;
                                housecount++;
                                House house = Mapper.Map <HouseDto, House>(houseDto);
                                //给house各属性赋值
                                house.BuildingId   = eBuilding.BuildingId;
                                house.Valid        = 1;
                                house.FxtCompanyId = fxtCompanyId;
                                house.CityID       = cityId;
                                if (string.IsNullOrEmpty(houseDto.UnitNo) && string.IsNullOrEmpty(houseDto.HouseNo))
                                {
                                    house.UnitNo = houseDto.HouseName.Replace(houseDto.FloorNo.ToString(), "$");
                                }
                                else
                                {
                                    house.UnitNo = _houseService.SetHouseUnitNoAndHouseNo(house.UnitNo, houseDto.HouseNo);
                                }
                                //设置新增实体
                                if (houseDto.Valid == 0)
                                {
                                    var hou = _unitOfWork.HouseRepository.GetBy(m => m.AppId == houseDto.AppId && m.BuildingId == eBuilding.BuildingId);
                                    if (hou != null)
                                    {
                                        _unitOfWork.HouseDetailsRepository.Delete(m => m.HouseId == hou.HouseId);
                                        _unitOfWork.HouseRepository.Delete(m => m.AppId == houseDto.AppId && m.BuildingId == eBuilding.BuildingId);
                                    }
                                }
                                else
                                {
                                    House eHouse = eBuilding.Houses == null ? null : eBuilding.Houses.Where(m => m.AppId == houseDto.AppId && m.BuildingId == eBuilding.BuildingId && m.Valid == 1).FirstOrDefault();
                                    if (eHouse == null)
                                    {
                                        house.CreateTime = nowTime;
                                        house.Creator    = userName;
                                        eHouse           = house;
                                        if (eBuilding.Houses == null)
                                        {
                                            eBuilding.Houses = new List <House>();
                                        }
                                        eBuilding.Houses.Add(eHouse);
                                    }
                                    else
                                    {
                                        eHouse.BuildArea     = house.BuildArea;
                                        eHouse.EndFloorNo    = house.EndFloorNo;
                                        eHouse.FloorNo       = house.FloorNo;
                                        eHouse.FrontCode     = house.FrontCode;
                                        eHouse.HouseName     = house.HouseName;
                                        eHouse.HouseTypeCode = house.HouseTypeCode;
                                        eHouse.NoiseCode     = house.NoiseCode;
                                        eHouse.NominalFloor  = house.NominalFloor;
                                        eHouse.PhotoName     = house.PhotoName;
                                        eHouse.PurposeCode   = house.PurposeCode;
                                        eHouse.Remark        = house.Remark;
                                        eHouse.SightCode     = house.SightCode;
                                        eHouse.Status        = house.Status;
                                        eHouse.StructureCode = house.StructureCode;
                                        eHouse.UnitNo        = house.UnitNo;
                                        eHouse.VDCode        = house.VDCode;
                                        eHouse.SaveUser      = userName;
                                        eHouse.SaveDateTime  = nowTime;
                                    }
                                    //生成房号
                                    if (house.EndFloorNo >= house.FloorNo)
                                    {
                                        string unitNo  = _houseService.GetUnitNoByUnitNoStr(house.UnitNo);
                                        string houseNo = _houseService.GetHouseNoByUnitNoStr(house.UnitNo);
                                        for (int i = house.FloorNo; i <= house.EndFloorNo; i++)
                                        {
                                            housedetailcount++;
                                            List <int> cs = new List <int>()
                                            {
                                                SYSCodeManager.HOUSEPURPOSECODE_5, SYSCodeManager.HOUSEPURPOSECODE_6, SYSCodeManager.HOUSEPURPOSECODE_8, SYSCodeManager.HOUSEPURPOSECODE_27
                                            };
                                            HouseDetails detail = new HouseDetails();
                                            detail              = Mapper.Map <House, HouseDetails>(eHouse);
                                            detail.FloorNo      = i;
                                            detail.NominalFloor = i.ToString();
                                            detail.UnitNo       = unitNo;
                                            detail.RoomNo       = houseNo;
                                            detail.CreateTime   = nowTime;
                                            detail.Creator      = userName;
                                            if (detail.PurposeCode.HasValue && cs.Contains(detail.PurposeCode.Value))
                                            {
                                                detail.HouseName = unitNo + houseNo;
                                            }
                                            else
                                            {
                                                if (i < 0)
                                                {
                                                    detail.HouseName = "-" + unitNo + -i + houseNo;
                                                }
                                                else
                                                {
                                                    detail.HouseName = unitNo + i + houseNo;
                                                }
                                            }

                                            if (i != 0)
                                            {
                                                if (eHouse.HouseDetails == null)
                                                {
                                                    eHouse.HouseDetails = new List <HouseDetails>();
                                                }
                                                var hd = eHouse.HouseDetails.Where(m => m.HouseId == detail.HouseId && m.RoomNo == houseNo && m.UnitNo == detail.UnitNo && m.FloorNo == detail.FloorNo).FirstOrDefault();
                                                if (hd == null)
                                                {
                                                    eHouse.HouseDetails.Add(detail);
                                                }
                                                else
                                                {
                                                    hd.FloorNo       = detail.FloorNo;
                                                    hd.FrontCode     = detail.FrontCode;
                                                    hd.HouseName     = detail.HouseName;
                                                    hd.HouseTypeCode = detail.HouseTypeCode;
                                                    hd.NoiseCode     = detail.NoiseCode;
                                                    hd.NominalFloor  = detail.NominalFloor;
                                                    hd.PurposeCode   = detail.PurposeCode;
                                                    hd.Remark        = detail.Remark;
                                                    hd.SightCode     = detail.SightCode;
                                                    hd.StructureCode = detail.StructureCode;
                                                    hd.UnitNo        = detail.UnitNo;
                                                    hd.VDCode        = detail.VDCode;
                                                    hd.SaveUser      = userName;
                                                    hd.SaveDateTime  = nowTime;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                    }

                    swbs.Stop();
                    log.Info("循环一个楼栋需要" + swbs.Elapsed.TotalMilliseconds + "ms.");
                }
            }
            #endregion
            //更新任务
            allotFlow.StateCode = SYSCodeManager.STATECODE_4;
            allotFlow.StateDate = nowTime;
            allotFlow.X         = projectDto.X;
            allotFlow.Y         = projectDto.Y;

            returnAllotId   = allotFlow.Id;
            returnProjectId = allotFlow.Project.ProjectId;

            sw.Stop();
            TimeSpan ts2 = sw.Elapsed;
            if (projectDto.BuildingDtolist != null)
            {
                log.Info("楼栋:" + projectDto.BuildingDtolist.Count + "条.");
                log.Info("单元室号:" + housecount + "条.");
                log.Info("房号:" + housedetailcount + "条.");
            }
            log.Info("循环操作总共花费" + ts2.TotalMilliseconds + "ms.");
            Stopwatch sw2 = new Stopwatch();
            sw2.Start();
            int      r   = _unitOfWork.Commit();
            TimeSpan ts3 = sw2.Elapsed;
            log.Info("执行数据库操作总共花费" + ts3.TotalMilliseconds + "ms.");

            return(r);
        }
コード例 #5
0
ファイル: AllotFlowService.cs プロジェクト: kingshhh/fxtcode
        public int ImportToDataCenter(long allowId, int cityId, int companyId, string userName, string userTrueName, string signName, List <UserCenter_Apps> appList, out string message)
        {
            AllotFlow allot = _unitOfWork.AllotFlowRepository.GetById(allowId);

            if (allot == null || allot.StateCode != SYSCodeManager.STATECODE_8)
            {
                message = "入库失败:该任务不存在或者该任务状态不为审核通过";
                return(0);
            }
            if (allot.DatType == SYSCodeManager.DATATYPECODE_1)
            {
                Project proj = _unitOfWork.ProjectRepository.GetBy(m => m.ProjectId == allot.DatId && m.CityID == cityId);
                if (proj == null)
                {
                    message = "入库失败:楼盘不存在";
                    return(0);
                }
                List <PCompany>   lnkpc = _unitOfWork.P_CompanyRepository.Get(m => m.ProjectId == proj.ProjectId && m.CityId == cityId).ToList();
                List <PAppendage> lnkpa = _unitOfWork.P_AppendageRepository.Get(m => m.ProjectId == proj.ProjectId && m.CityId == cityId).ToList();
                var bList = _unitOfWork.BuildingRepository.Get(m => m.ProjectId == proj.ProjectId && m.CityID == cityId);
                var hList = _unitOfWork.HouseDetailsRepository.Get();
                List <HouseDetails> houseList = (from b in bList
                                                 join h in hList on b.BuildingId equals h.BuildingId
                                                 select h).ToList();
                List <Building> buildingList = bList.ToList();
                //List<HouseDetails> copyHouseList = new List<HouseDetails>();//用于传给数据中心存储的
                //批量生产房号
                //foreach (DATHouse house in houseList)
                //{
                //    /////////获取单元号+室号////////////
                //    string unitNoStr = house.UnitNo;
                //    int startFloor = house.FloorNo;
                //    int endFloor = Convert.ToInt32(house.EndFloorNo);
                //    if (house.EndFloorNo != null && Convert.ToInt32(house.EndFloorNo) < house.FloorNo)//输入的结束楼层小于起始楼层则调过来递增
                //    {
                //        startFloor = Convert.ToInt32(house.EndFloorNo);
                //        endFloor = house.FloorNo;
                //    }
                //    string unitNo = DATHouseManager.GetUnitNoByUnitNoStr(house.UnitNo);
                //    string houseNo = DATHouseManager.GetHouseNoByUnitNoStr(house.UnitNo);
                //    //////循环生成房号//////////////////
                //    int nowFloor = house.FloorNo;
                //    for (int i = startFloor; (i <= Convert.ToInt32(endFloor) && house.EndFloorNo != null) || i == startFloor; i++)
                //    {
                //        DATHouse _house = house.CopyEntity<DATHouse>();
                //        _house.UnitNo = unitNo + houseNo;
                //        _house.FloorNo = i;
                //        _house.HouseName = unitNo + i + houseNo;

                //        if (copyHouseList.Where(obj => obj.BuildingId == _house.BuildingId && obj.FloorNo == _house.FloorNo && obj.HouseName == _house.HouseName).FirstOrDefault() == null)
                //        {
                //            copyHouseList.Add(_house);
                //        }
                //    }
                //}
                List <Building> resultBuildings = new List <Building>();//返回的楼栋ids
                int             fxtprojectId    = DataCenterProjectApi.ImportProjectData(proj, lnkpc, lnkpa, buildingList, ref resultBuildings, houseList, userName, signName, appList, out message);
                if (fxtprojectId <= 0)
                {
                    message = "入库失败:导入楼盘信息异常";
                    return(0);
                }

                if (resultBuildings != null && resultBuildings.Count > 0)
                {
                    foreach (var item in resultBuildings)
                    {
                        var building = _unitOfWork.BuildingRepository.GetById(item.BuildingId);
                        if (building.FxtBuildingId != item.FxtBuildingId)
                        {
                            building.FxtBuildingId = item.FxtBuildingId;
                            _unitOfWork.BuildingRepository.Update(building);
                        }
                    }
                }

                proj.FxtProjectId = fxtprojectId;
                _unitOfWork.ProjectRepository.Update(proj);
                //上传照片
                List <PPhoto> photoList = _unitOfWork.P_PhotoRepository.Get(m => m.ProjectId == proj.ProjectId && m.CityId == cityId && m.FxtCompanyId == companyId).ToList();
                foreach (PPhoto pObj in photoList)
                {
                    //FileStream fStream = new FileStream(System.Web.HttpContext.Current.Server.MapPath(pObj.Path), FileMode.Open, FileAccess.Read);
                    var path = ConfigurationManager.AppSettings["OssDownload"] + pObj.Path;
                    using (WebClient client = new WebClient())
                    {
                        var data = client.DownloadData(path);
                        //BinaryReader bReader = new BinaryReader(fStream);//将文件了加载成二进制数据
                        //long length = bReader.BaseStream.Length;//当前文件的总大小
                        ////创建一个用于存储要上传文件内容的字节对象
                        //byte[] data = new byte[length];
                        ////将流中读取指定字节数加载到到字节对象data
                        //bReader.Read(data, 0, Convert.ToInt32(length));
                        pObj.PhotoTypeCode = pObj.PhotoTypeCode.HasValue ? pObj.PhotoTypeCode.Value : 0;
                        long fxtbuildingid = 0;
                        //楼栋图片
                        if (pObj.BuildingId.HasValue && pObj.BuildingId > 0)
                        {
                            var nowBuilding = resultBuildings.Where(m => m.BuildingId == pObj.BuildingId).FirstOrDefault();
                            if (nowBuilding != null)
                            {
                                fxtbuildingid = Convert.ToInt64(nowBuilding.FxtBuildingId);
                            }
                        }
                        if (DataCenterProjectApi.AddProjectPhoto(fxtprojectId, fxtbuildingid, cityId, pObj.PhotoTypeCode.Value, new FileInfo(System.Web.HttpContext.Current.Server.MapPath(pObj.Path)).Name, pObj.PhotoName, data, userName, signName, appList, out message) != 1)
                        {
                            message = "入库失败:上传楼盘照片失败(id:" + pObj.Id + ")";
                            return(0);
                        }
                    }
                }
                //设置为已入库
                proj.Status = SYSCodeManager.STATECODE_10;
                _unitOfWork.ProjectRepository.Update(proj);
            }
            //设置为已入库
            allot.StateCode = SYSCodeManager.STATECODE_10;
            allot.StateDate = DateTime.Now;
            _unitOfWork.AllotFlowRepository.Update(allot);
            //记录日志
            _unitOfWork.AllotSurveyRepository.Insert(new AllotSurvey()
            {
                AllotId      = allowId,
                CityId       = cityId,
                FxtCompanyId = companyId,
                UserName     = userName,
                StateCode    = SYSCodeManager.STATECODE_10,
                StateDate    = DateTime.Now,
                CreateDate   = DateTime.Now,
                TrueName     = userTrueName,
                Remark       = "<span class=\"red\">入库</span>"
            });
            message = "入库成功!";
            return(_unitOfWork.Commit() > 0 ? 1 : 0);
        }
コード例 #6
0
        public ActionResult Call(string ids, UserCenter_LoginUserInfo loginUserInfo)
        {
            string mes = string.Empty;

            try
            {
                List <CAS.Entity.DBEntity.DATProject> projectList = DataCenterProjectApi.GetProjectBuildingHouse(loginUserInfo.NowCityId, ids, loginUserInfo.UserName, loginUserInfo.SignName, loginUserInfo.AppList);
                //log.Info("数据中心楼盘:" + projectList.Count);
                if (projectList != null && projectList.Count > 0)
                {
                    foreach (var item in projectList)
                    {
                        //行政区 + 楼盘名称||已有的projectid||没有入库
                        var exists = _unitOfWork.ProjectRepository.Get(m =>
                                                                       (m.ProjectName == item.projectname ||
                                                                        m.ProjectName == item.areaname + item.projectname ||
                                                                        m.FxtProjectId == item.projectid) && m.Status != SYSCodeManager.STATECODE_10
                                                                       ).FirstOrDefault();
                        if (exists != null)
                        {
                            mes += item.projectname + ",";
                            continue;//任务重复
                        }
                        DateTime now = DateTime.Now;
                        //楼盘
                        Project project = Mapper.Map <CAS.Entity.DBEntity.DATProject, Project>(item);
                        project.FxtProjectId = item.projectid;
                        project.FxtCompanyId = item.fxtcompanyid;
                        project.Status       = SYSCodeManager.STATECODE_1;
                        project.ProjectId    = 0;
                        project.CreateTime   = now;
                        project.X            = item.projectx;
                        project.Y            = item.projecty;
                        project.Valid        = 1;
                        //_unitOfWork.ProjectRepository.Insert(project);
                        project = _unitOfWork.ProjectRepository.Insert(project);
                        _unitOfWork.Commit();
                        //任务
                        var allot = new AllotFlow()
                        {
                            CityId       = project.CityID,
                            CreateTime   = now,
                            DatType      = SYSCodeManager.DATATYPECODE_1,
                            FxtCompanyId = project.FxtCompanyId.Value,
                            UserName     = loginUserInfo.UserName,
                            UserTrueName = loginUserInfo.TrueName,
                            StateCode    = SYSCodeManager.STATECODE_1,
                            DatId        = project.ProjectId,
                            StateDate    = now
                        };
                        allot = _unitOfWork.AllotFlowRepository.Insert(allot);
                        //_unitOfWork.Commit();
                        //任务记录
                        var allotSurvey = new AllotSurvey()
                        {
                            AllotId    = allot.Id,
                            CityId     = allot.CityId,
                            CreateDate = now,
                            StateCode  = SYSCodeManager.STATECODE_1,
                            StateDate  = now,
                            UserName   = loginUserInfo.UserName,
                            TrueName   = loginUserInfo.TrueName,
                            Remark     = "从调度中心(数据中心) <span class=\"red\">导入任务</span>"
                        };
                        allotSurvey = _unitOfWork.AllotSurveyRepository.Insert(allotSurvey);
                        //停车状况
                        var parkingStatus = _unitOfWork.P_AppendageRepository.Get(m => m.AppendageCode == SYSCodeManager.APPENDAGECODE_14 && m.CityId == project.CityID && m.ProjectId == project.ProjectId).FirstOrDefault();
                        if (parkingStatus != null)
                        {
                            parkingStatus.ClassCode = project.ParkingStatus;
                            _unitOfWork.P_AppendageRepository.Update(parkingStatus);
                        }
                        else
                        {
                            parkingStatus               = new PAppendage();
                            parkingStatus.ClassCode     = project.ParkingStatus;
                            parkingStatus.AppendageCode = SYSCodeManager.APPENDAGECODE_14;
                            parkingStatus.CityId        = project.CityID;
                            parkingStatus.ProjectId     = project.ProjectId;
                            parkingStatus.IsInner       = true;
                            _unitOfWork.P_AppendageRepository.Insert(parkingStatus);
                        }
                        //开发商
                        if (!string.IsNullOrEmpty(item.devecompanyname))
                        {
                            var developcompany = _unitOfWork.P_CompanyRepository.Get(m => m.CompanyName == item.devecompanyname && m.CompanyType == SYSCodeManager.COMPANYTYPECODE_1 &&
                                                                                     m.ProjectId == project.ProjectId && m.CityId == project.CityID).FirstOrDefault();
                            if (developcompany == null)
                            {
                                developcompany             = new PCompany();
                                developcompany.CityId      = project.CityID;
                                developcompany.CompanyName = item.devecompanyname;
                                developcompany.CompanyType = SYSCodeManager.COMPANYTYPECODE_1;
                                developcompany.ProjectId   = project.ProjectId;
                                _unitOfWork.P_CompanyRepository.Insert(developcompany);
                            }
                        }
                        //物管公司
                        if (!string.IsNullOrEmpty(item.managercompanyname))
                        {
                            var managercompany = _unitOfWork.P_CompanyRepository.Get(m => m.CompanyName == item.managercompanyname && m.CompanyType == SYSCodeManager.COMPANYTYPECODE_4 &&
                                                                                     m.ProjectId == project.ProjectId && m.CityId == project.CityID).FirstOrDefault();
                            if (managercompany == null)
                            {
                                managercompany             = new PCompany();
                                managercompany.CityId      = project.CityID;
                                managercompany.CompanyName = item.managercompanyname;
                                managercompany.CompanyType = SYSCodeManager.COMPANYTYPECODE_4;
                                managercompany.ProjectId   = project.ProjectId;
                                _unitOfWork.P_CompanyRepository.Insert(managercompany);
                            }
                        }
                    }
                    _unitOfWork.Commit();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            if (!string.IsNullOrEmpty(mes))
            {
                //mes += "部分任务导入完成,楼盘:";
                mes += ",不能重复导入。";
            }
            return(Json(new { result = 1, message = mes }));
        }