Esempio n. 1
0
        public CustomUserInfoVM GetUserInfo(int uid)
        {
            CustomUserInfoVM     userVM      = new CustomUserInfoVM();
            List <SystemRoleDTO> roleDTOList = new List <SystemRoleDTO>();
            var userInfo = systemUserRepository.GetById(uid);

            userVM = AutoMapper.Mapper.Map <CustomUserInfoVM>(userInfo);

            foreach (var item in userInfo.System_User_Role)
            {
                roleDTOList.Add(AutoMapper.Mapper.Map <SystemRoleDTO>(item.System_Role));
            }
            userVM.RoleList = roleDTOList;


            //获取用户所在的厂区和所属的4级信息
            userVM.OrgInfo = GetOrgInfoByUserUId(userInfo.Account_UID);

            //排除掉超级管理员只设定Site其他都没设定的情况,不然会取到值为null的数据
            var opTypes      = userVM.OrgInfo.Where(m => m.OPType != null).Select(m => m.OPType).ToList();
            var orgUIDList   = userVM.OrgInfo.Where(m => m.OPType != null).Select(m => m.OPType_OrganizationUID.Value).ToList();
            var plantUIDList = userVM.OrgInfo.Select(m => m.Plant_OrganizationUID.Value).ToList();

            userVM.OpTypes = opTypes;
            userVM.OPType_OrganizationUIDList = orgUIDList;
            userVM.Plant_OrganizationUIDList  = plantUIDList;
            //获取当前用户所拥有的Flowchart专案列表
            userVM.ProjectUIDList  = GetProjectUIDList(uid);
            userVM.projectTypeList = GetProjectNameList(uid);


            return(userVM);
        }
Esempio n. 2
0
        public void SetFlowchartWipAndPlan(CustomUserInfoVM userInfo, List <FlowChartImportDetailDTO> detailDTOList, FlowChartMasterDTO newMaster, out List <int> idList)
        {
            idList = new List <int>();
            //获取上个版本的FLowchartDetail数据
            var api = string.Format("FlowChart/QueryDetailList?id={0}&Version={1}", newMaster.FlowChart_Master_UID, newMaster.FlowChart_Version);
            HttpResponseMessage message = APIHelper.APIGetAsync(api);
            var json = message.Content.ReadAsStringAsync().Result;
            var flowchartOldVersionList = JsonConvert.DeserializeObject <List <FlowChartDetailDTO> >(json);

            idList = flowchartOldVersionList.Select(m => m.FlowChart_Detail_UID).ToList();
            var idListJson = JsonConvert.SerializeObject(idList);
            //获取上个版本的生产计划数据包含这周和下周的数据
            var mgApi = "FlowChart/QueryFLMgDataList";
            HttpResponseMessage myApiMessage = APIHelper.APIPostAsync(idListJson, mgApi);
            var myApiJson = myApiMessage.Content.ReadAsStringAsync().Result;
            List <FlowChartMgDataDTO> mgList = JsonConvert.DeserializeObject <List <FlowChartMgDataDTO> >(myApiJson);
            //获取上个版本的绑定物料员数据
            var myBomApi = "FlowChart/QueryFLBomDataList";
            HttpResponseMessage myBomApiMessage = APIHelper.APIPostAsync(idListJson, myBomApi);
            var myBomApiJson = myBomApiMessage.Content.ReadAsStringAsync().Result;
            List <FlowChartPCMHRelationshipDTO> bomList = JsonConvert.DeserializeObject <List <FlowChartPCMHRelationshipDTO> >(myBomApiJson);

            //循环Excel中获取的列表
            foreach (var detailDTOItem in detailDTOList)
            {
                //通过绑定序号列找到老版本的FlowChart_Detail_UID
                var hasItem = flowchartOldVersionList.Where(m => m.Binding_Seq == detailDTOItem.FlowChartDetailDTO.Binding_Seq).FirstOrDefault();
                if (hasItem != null)
                {
                    //WIP的数量已经在excel里面设置了,不需要读取上一次的记录了
                    //detailDTOItem.FlowChartDetailDTO.WIP_QTY = hasItem.WIP_QTY;
                    detailDTOItem.FlowChartDetailDTO.Old_FlowChart_Detail_UID = hasItem.FlowChart_Detail_UID;
                    //通过老版本的FlowChart_Detail_UID去生产计划表里找到这周和下周的该制程所有的生产计划
                    var hasMgList = mgList.Where(m => m.FlowChart_Detail_UID == hasItem.FlowChart_Detail_UID).ToList();
                    //将生产计划这周和下载的数据绑定到新版本的数据中,这样一个FlowChartDetailDTO类型对应一个MgDataList列表,但是在数据插入时FlowChart_Detail_UID已经变为新的值了,所以后面插入还要再处理
                    detailDTOItem.MgDataList = hasMgList;
                    //将老版本的绑定物料员绑定到新版本的item中
                    var pcList = bomList.Where(m => m.FlowChart_Detail_UID == hasItem.FlowChart_Detail_UID).ToList();//只会1对1,ToList是为了转换对象方便
                    if (pcList != null && pcList.Count() > 0)
                    {
                        pcList.First().Modified_UID  = userInfo.Account_UID;
                        pcList.First().Modified_Date = DateTime.Now;
                    }
                    detailDTOItem.PCMHList = pcList;
                }
            }
        }
Esempio n. 3
0
        public ProductionPlanningReportGetProject GetProjectList(CustomUserInfoVM vm)
        {
            ProductionPlanningReportGetProject projectItem = new ProductionPlanningReportGetProject();
            Dictionary <int, string>           plantDir    = new Dictionary <int, string>();
            Dictionary <int, string>           opTypeDir   = new Dictionary <int, string>();
            Dictionary <int, string>           funPlantDir = new Dictionary <int, string>();

            var plantList = systemOrgRepository.GetMany(m => m.Organization_ID.Contains("1000")).OrderBy(m => m.Organization_ID).ToList();

            foreach (var item in plantList)
            {
                plantDir.Add(item.Organization_UID, item.Organization_Desc);
            }

            var id           = plantDir.First().Key;
            var childUIDList = systemOrgBomRepository.GetMany(m => m.ParentOrg_UID == id).Select(m => m.ChildOrg_UID).ToList();
            var optypeList   = systemOrgRepository.GetMany(m => childUIDList.Contains(m.Organization_UID)).ToList();

            foreach (var item in optypeList)
            {
                opTypeDir.Add(item.Organization_UID, item.Organization_Desc);
            }
            opTypeDir.Add(StructConstants.ReportStatus.AllKey, StructConstants.ReportStatus.AllValue);

            var funPlantList = systemOrgRepository.GetChildByParentUID(vm.OPType_OrganizationUIDList.FirstOrDefault());

            foreach (var item in funPlantList)
            {
                funPlantDir.Add(item.Organization_UID, item.Organization_Name);
            }

            projectItem.plantDir  = plantDir;
            projectItem.opTypeDir = opTypeDir;
            //projectItem.FunPlantDir = funPlantDir;
            //projectItem.partTypeDir = partTypeDir;
            return(projectItem);
        }
Esempio n. 4
0
        public string SetAndCheckExcelContent(List <FlowChartImportDetailDTO> detailDTOList, bool isEdit, ExcelWorksheet worksheet, int iRow, int totalRows, FlowChartMasterDTO newMaster, string FlowChart_Version_Comment, CustomUserInfoVM userInfo)
        {
            string errorInfo = string.Empty;
            //内容样式设置
            var propertiesContent = FlowchartImportCommon.GetEtransferContentColumn();

            //获取所有厂别
            //不考虑跨厂区权限,他们不会操作只会浏览,默认取第一个,通过三级权限获取四级
            var plantAPI = "FlowChart/QueryAllFunctionPlantsAPI?optypeUID=" + userInfo.OrgInfo.First().OPType_OrganizationUID;
            //HttpResponseMessage message = APIHelper.APIPostAsync(null,plantAPI);
            HttpResponseMessage message = APIHelper.APIGetAsync(plantAPI);
            var jsonPlants     = message.Content.ReadAsStringAsync().Result;
            var functionPlants = JsonConvert.DeserializeObject <List <SystemFunctionPlantDTO> >(jsonPlants);

            //从第四行开始读取
            iRow = iRow + 2;
            //绑定序号        //制程序号没用    //厂别               //阶层
            int Binding_Seq, Process_Seq = 1, System_FunPlant_UID, Product_Stage;

            //DRI       //场地 //工站名稱  //厂别   //颜色  //工站說明     //返工设定      //检测设定      //制程序号
            string DRI, Place, Process, plantName, Color, Process_Desc, Rework_Setting, Check_Setting, ItemNo, Edition, FromWHS, ToWHSOK, ToWHSNG;

            //返修站点数量,每个FlowChart只能允许1个站点是返工站点,颜色可以不同
            List <int> CheckRepair = new List <int>();
            //这是真正的excel行数,totalRows的行数是错误的
            int    realTotalRows = 0;
            string lastItemNo = string.Empty, lastFromWHS = string.Empty, lastToWHSOK = string.Empty, lastToWHSNG = string.Empty;
            bool   firstRow = true;

            for (var i = iRow; i <= totalRows; i++)
            {
                //绑定序号
                Binding_Seq = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "绑定序号")].Value);
                //制程序号
                ItemNo = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "制程序号")].Value);


                FromWHS = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "FromWHS")].Value);
                ToWHSOK = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "ToWHSOK")].Value);
                ToWHSNG = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "ToWHSNG")].Value);


                if (firstRow)//如果是第一行开始循环则赋值
                {
                    lastItemNo  = ItemNo;
                    lastFromWHS = FromWHS;
                    lastToWHSNG = ToWHSNG;
                    lastToWHSOK = ToWHSOK;
                }
                else //如果不是第一行则开始判断
                {
                    if (lastItemNo == ItemNo)//如果上一个制程等于这一个制程的序号,则说明是同一制程
                    {
                        if (lastFromWHS != FromWHS || lastToWHSNG != ToWHSNG || lastToWHSOK != ToWHSOK)
                        {
                            //跳出循环
                            errorInfo = string.Format("第[{0}]行FromWHS,ToWHSOK,ToWHSNG不跟上一制程一致", i);
                            return(errorInfo);
                        }
                    }
                    else
                    {
                        lastItemNo  = ItemNo;
                        lastFromWHS = FromWHS;
                        lastToWHSNG = ToWHSNG;
                        lastToWHSOK = ToWHSOK;
                    }
                }
                firstRow = false;



                DRI = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "DRI")].Value);
                if (string.IsNullOrWhiteSpace(DRI))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行DRI不能为空", i);
                    return(errorInfo);
                }
                Place = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "场地")].Value);
                if (string.IsNullOrWhiteSpace(Place))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行场地不能为空", i);
                    return(errorInfo);
                }
                Process = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "工站名稱")].Value);
                if (string.IsNullOrWhiteSpace(Process))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行工站名稱不能为空", i);
                    return(errorInfo);
                }
                plantName = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "厂别")].Value) ?? string.Empty;
                if (string.IsNullOrWhiteSpace(plantName))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行厂别不能为空", i);
                    return(errorInfo);
                }

                var hasItem = functionPlants.FirstOrDefault(m => m.FunPlant.ToLower() == plantName.ToLower().Trim());
                if (hasItem != null)
                {
                    System_FunPlant_UID = hasItem.System_FunPlant_UID;
                }
                else
                {
                    //跳出循环
                    errorInfo = string.Format("厂别[{0}]输入不正确", plantName);
                    return(errorInfo);
                }


                Product_Stage = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "阶层")].Value);
                Color         = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "颜色")].Value) ?? string.Empty;
                Edition       = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "Edition")].Value);
                Process_Desc  = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "工站說明")].Value);

                Rework_Setting = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "返工设定")].Value);
                if (Rework_Setting == "Repair")
                {
                    CheckRepair.Add(Process_Seq);
                }
                if (CheckRepair.Distinct().ToList().Count > 1)
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行出现重复的修复站点!", i);
                    return(errorInfo);
                }

                //检测站点赋值
                var CheckTemp = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "检测设定")].Value);
                if (!string.IsNullOrWhiteSpace(CheckTemp))
                {
                    CheckTemp = CheckTemp.Trim();
                }

                switch (CheckTemp)
                {
                case StructConstants.IsQAProcessType.InspectText:     //IPQC全检
                    Check_Setting = StructConstants.IsQAProcessType.InspectKey;
                    break;

                case StructConstants.IsQAProcessType.PollingText:     //IPQC巡检
                    Check_Setting = StructConstants.IsQAProcessType.PollingKey;
                    break;

                case StructConstants.IsQAProcessType.InspectOQCText:     //OQC检测
                    Check_Setting = StructConstants.IsQAProcessType.InspectOQCKey;
                    break;

                case StructConstants.IsQAProcessType.InspectAssembleText:     //组装检测
                    Check_Setting = StructConstants.IsQAProcessType.InspectAssembleKey;
                    break;

                case StructConstants.IsQAProcessType.AssembleOQCText:     //组装&OQC检测
                    Check_Setting = StructConstants.IsQAProcessType.AssembleOQCKey;
                    break;

                default:
                    Check_Setting = string.Empty;
                    break;
                }


                FlowChartImportDetailDTO detailDTOItem = new FlowChartImportDetailDTO();

                FlowChartDetailDTO newDetailDtoItem = new FlowChartDetailDTO();
                newDetailDtoItem.FlowChart_Master_UID = newMaster.FlowChart_Master_UID;
                newDetailDtoItem.System_FunPlant_UID  = System_FunPlant_UID;
                newDetailDtoItem.Binding_Seq          = Binding_Seq;
                var seq = Process_Seq++;
                newDetailDtoItem.Process_Seq               = seq.ToString();
                newDetailDtoItem.DRI                       = DRI;
                newDetailDtoItem.Place                     = Place;
                newDetailDtoItem.Process                   = Process;
                newDetailDtoItem.Product_Stage             = Product_Stage;
                newDetailDtoItem.Color                     = Color;
                newDetailDtoItem.Edition                   = Edition;
                newDetailDtoItem.Process_Desc              = Process_Desc;
                newDetailDtoItem.FlowChart_Version_Comment = FlowChart_Version_Comment;
                newDetailDtoItem.Rework_Flag               = Rework_Setting;
                //新增QA字段
                newDetailDtoItem.IsQAProcess   = Check_Setting;
                newDetailDtoItem.Modified_UID  = newMaster.Modified_UID;
                newDetailDtoItem.Modified_Date = newMaster.Modified_Date;
                newDetailDtoItem.BeginTime     = DateTime.Now;
                newDetailDtoItem.ItemNo        = ItemNo;
                newDetailDtoItem.FromWHS       = FromWHS;
                newDetailDtoItem.ToWHSNG       = ToWHSNG;
                newDetailDtoItem.ToWHSOK       = ToWHSOK;
                if (isEdit)
                {
                    //存到临时表里面的数据所以要加1
                    newDetailDtoItem.FlowChart_Version = newMaster.FlowChart_Version + 1;
                }
                else
                {
                    //存到正式表里面的数据不用加1
                    newDetailDtoItem.FlowChart_Version = newMaster.FlowChart_Version;
                }

                detailDTOItem.FlowChartDetailDTO = newDetailDtoItem;
                //detailDTOItem.FlowChartMgDataDTO = newMgDataDtoItem;
                detailDTOList.Add(detailDTOItem);

                //行数加1
                realTotalRows++;
            }

            var bindingSeqCount = detailDTOList.GroupBy(m => m.FlowChartDetailDTO.Binding_Seq).Select(m => m.Key).Count();
            //var processSeqCount = detailDTOList.GroupBy(m => m.FlowChartDetailDTO.Process_Seq).Select(m => m.Key).Count();
            var rowCount = realTotalRows;

            if (bindingSeqCount != rowCount)
            {
                errorInfo = "绑定序号有重复项,请修改";
                return(errorInfo);
            }
            //if (processSeqCount != rowCount)
            //{
            //    errorInfo = "制程序号有重复项,请修改";
            //    return errorInfo;
            //}

            return(errorInfo);
        }
Esempio n. 5
0
        public string CheckFlowchartIsMatch(FlowChartExcelImportParas paraItem, FlowChartMasterDTO newMaster, bool isEdit, string FlowChart_Version_Comment, string Part_Types, CustomUserInfoVM userInfo, out string projectUIDOrFLMasterUID)
        {
            string errorInfo = string.Empty;
            var    orgList   = userInfo.OrgInfo.Select(m => m.OPType_OrganizationUID.Value).ToList();

            paraItem.Organization_UIDList = orgList;
            if (isEdit)
            {
                paraItem.isEdit = true;
            }
            else
            {
                paraItem.isEdit = false;
            }
            var apiUrl = string.Format("FlowChart/CheckFlowChartAPI");
            HttpResponseMessage responMessage = APIHelper.APIPostAsync(paraItem, apiUrl);

            projectUIDOrFLMasterUID = responMessage.Content.ReadAsStringAsync().Result;
            projectUIDOrFLMasterUID = projectUIDOrFLMasterUID.Replace("\"", "");
            //正确返回id字符串,错误则返回出错字符串
            if (!FlowchartImportCommon.ValidIsInt(projectUIDOrFLMasterUID, isEdit))
            {
                errorInfo = projectUIDOrFLMasterUID;
                return(errorInfo);
            }

            if (isEdit)
            {
                var idList = projectUIDOrFLMasterUID.Split('_').ToList();
                newMaster.FlowChart_Master_UID = Convert.ToInt32(idList[0]);
                newMaster.Project_UID          = Convert.ToInt32(idList[1]);
                newMaster.FlowChart_Version    = Convert.ToInt32(idList[2]);
                newMaster.Organization_UID     = Convert.ToInt32(idList[3]);
                newMaster.Modified_UID         = userInfo.Account_UID;
                newMaster.Modified_Date        = DateTime.Now;


                //检查当前时间段是否包含有ProductInput的制程信息
                string productapiUrl = string.Format("ProductInput/CheckHasExistProcessAPI?MasterUID={0}&Version={1}", newMaster.FlowChart_Master_UID, newMaster.FlowChart_Version);
                HttpResponseMessage productResponMessage = APIHelper.APIGetAsync(productapiUrl);
                var hasProcess = productResponMessage.Content.ReadAsStringAsync().Result;
                if (hasProcess == "true")
                {
                    errorInfo = "当前Flowchart的相关制程还未完全录入,不能导入新版本";
                    return(errorInfo);
                }
            }
            else
            {
                int tag = projectUIDOrFLMasterUID.IndexOf('_');
                newMaster.Project_UID       = Convert.ToInt32(projectUIDOrFLMasterUID.Substring(0, tag));
                newMaster.Organization_UID  = Convert.ToInt32(projectUIDOrFLMasterUID.Substring(tag + 1));
                newMaster.FlowChart_Version = 1;
                newMaster.Created_UID       = userInfo.Account_UID;
            }
            newMaster.Part_Types = Part_Types.Trim();
            newMaster.FlowChart_Version_Comment = FlowChart_Version_Comment;
            newMaster.Is_Latest     = true;
            newMaster.Is_Closed     = false;
            newMaster.Modified_UID  = userInfo.Account_UID;
            newMaster.Modified_Date = DateTime.Now;

            return(errorInfo);
        }
Esempio n. 6
0
        private void SetLogon(AuthorizedLoginUser user)
        {
            Session[SessionConstants.LoginTicket]       = user.Token;
            Session[SessionConstants.CurrentAccountUID] = user.Account_UID.ToString();
            Session[SessionConstants.CurrentUserName]   = user.User_Name;
            Session[SessionConstants.CurrentLanguageId] = user.System_Language_UID.ToString();

            // Session[SessionConstants.CurrentUserInfo] = AAresult;
            if (user.USER_Ntid.ToUpper() != "EQPUSER")
            {
                var userApiUrl      = string.Format("Common/GetUserInfo/?uid={0}", user.Account_UID);
                var AAresponMessage = APIHelper.APIGetAsync(userApiUrl);
                var AAresult        = JsonConvert.DeserializeObject <CustomUserInfoVM>(AAresponMessage.Content.ReadAsStringAsync().Result);

                Session[SessionConstants.CurrentUserInfo] = AAresult;
                string apiUrl        = string.Format("Common/GetLanguagesAPI?Language_UID={0}", user.System_Language_UID);
                var    responMessage = APIHelper.APIGetAsync(apiUrl);
                var    result        = responMessage.Content.ReadAsStringAsync().Result;
                var    languageVM    = JsonConvert.DeserializeObject <LanguageVM>(result);

                string userUrl           = string.Format("Common/GetUserInfo/?uid={0}", user.Account_UID);
                var    userResponMessage = APIHelper.APIGetAsync(userUrl);
                var    userResult        = userResponMessage.Content.ReadAsStringAsync().Result;

                var userDTO = JsonConvert.DeserializeObject <CustomUserInfoVM>(userResult);

                PISSessionContext.Current.CurrentWorkingLanguage = languageVM.CurrentLanguage;
                PISSessionContext.Current.CurrentUser            = userDTO;
                PISSessionContext.Current.Languages = languageVM.Languages;
                var userCookie = new HttpCookie(SessionConstants.UserSelect);
                userCookie[SessionConstants.CurrentAccountUID] = PISSessionContext.Current.CurrentUser.Account_UID.ToString();
                userCookie[SessionConstants.CurrentLanguageId] = PISSessionContext.Current.CurrentWorkingLanguage.System_Language_UID.ToString();
                userCookie.Expires.AddDays(365);
                HttpContext.Response.SetCookie(userCookie);

                //用于传值给前台JS
                Session[SessionConstants.CurrentLanguageId] = languageVM.CurrentLanguage.System_Language_UID;
            }
            else
            {
                var customUserInfoVM = new CustomUserInfoVM()
                {
                    Account_UID  = user.Account_UID,
                    Language_UID = 2,
                    User_NTID    = user.USER_Ntid,
                    User_Name    = user.User_Name,
                    MH_Flag      = user.MH_Flag,
                    LoginToken   = user.Token
                };
                Session[SessionConstants.CurrentUserInfo] = customUserInfoVM;
                string apiUrl        = string.Format("Common/GetLanguagesAPI?Language_UID={0}", 2);
                var    responMessage = APIHelper.APIGetAsync(apiUrl);
                var    result        = responMessage.Content.ReadAsStringAsync().Result;
                var    languageVM    = JsonConvert.DeserializeObject <LanguageVM>(result);
                PISSessionContext.Current.CurrentWorkingLanguage = languageVM.CurrentLanguage;
                PISSessionContext.Current.Languages = languageVM.Languages;
                //用于传值给前台JS
                Session[SessionConstants.CurrentLanguageId] = 2;

                // JsonConvert.DeserializeObject<CustomUserInfoVM>(customUserInfoVM)
            }
        }
Esempio n. 7
0
        public string SetAndCheckExcelContent(List <FlowChartImportDetailDTO> detailDTOList, bool isEdit, ExcelWorksheet worksheet, int iRow, int totalRows, FlowChartMasterDTO newMaster, string FlowChart_Version_Comment, CustomUserInfoVM userInfo)
        {
            string errorInfo = string.Empty;
            //内容样式设置
            var propertiesContent = FlowchartImportCommon.GetContentColumn();

            //获取所有厂别
            //不考虑跨厂区权限,他们不会操作只会浏览,默认取第一个,通过三级权限获取四级
            var plantAPI = "FlowChart/QueryAllFunctionPlantsAPI?optypeUID=" + userInfo.OrgInfo.First().OPType_OrganizationUID;
            //HttpResponseMessage message = APIHelper.APIPostAsync(null,plantAPI);
            HttpResponseMessage message = APIHelper.APIGetAsync(plantAPI);
            var jsonPlants     = message.Content.ReadAsStringAsync().Result;
            var functionPlants = JsonConvert.DeserializeObject <List <SystemFunctionPlantDTO> >(jsonPlants);

            //从第四行开始读取
            iRow = iRow + 2;
            //绑定序号        //制程序号    //厂别               //阶层         //WIP数量
            int Binding_Seq, Process_Seq, System_FunPlant_UID, Product_Stage, WIP, NullWip, Current_WH_QTY;

            //DRI       //场地 //工站名稱  //厂别   //颜色  //工站說明      //检测设定 //是否分楼栋     //返工设定 //对应返修站点
            string DRI, Place, Process, plantName, Color, Process_Desc, Check_Setting, Location_Flag, Rework_Setting, RelatedRepairBingdingSeq;
            //用来测试返工的填写是否正确
            List <int> idList = new List <int>();
            //这是真正的excel行数,totalRows的行数是错误的
            int realTotalRows = 0;
            var col           = worksheet.SelectedRange[1, 2];

            for (var i = iRow; i <= totalRows; i++)
            {
                //绑定序号
                Binding_Seq = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "绑定序号")].Value);
                //制程序号
                Process_Seq = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "制程序号")].Value);
                //循环结束,防止有空行
                if (Process_Seq == 0)
                {
                    break;
                }
                DRI = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "DRI")].Value);
                if (string.IsNullOrWhiteSpace(DRI))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行DRI不能为空", i);
                    return(errorInfo);
                }
                Place = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "场地")].Value);
                if (string.IsNullOrWhiteSpace(Place))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行场地不能为空", i);
                    return(errorInfo);
                }
                //接收空白字符,Y,N
                Location_Flag = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "是否分楼栋")].Value);
                if (string.IsNullOrWhiteSpace(Location_Flag))
                {
                    worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "是否分楼栋")].Value = "N";
                }
                else if (Location_Flag.ToUpper() != "Y" && Location_Flag.ToUpper() != "N")
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行是否分楼栋只能为Y,N 或空白字符", i);
                    return(errorInfo);
                }

                Process = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "工站名稱")].Value);
                if (string.IsNullOrWhiteSpace(Process))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行工站名稱不能为空", i);
                    return(errorInfo);
                }
                else
                {
                    Process = Process.Trim(); //去掉前后空格
                }
                plantName = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "厂别")].Value) ?? string.Empty;
                if (string.IsNullOrWhiteSpace(plantName))
                {
                    //跳出循环
                    errorInfo = string.Format("第[{0}]行厂别不能为空", i);
                    return(errorInfo);
                }

                var hasItem = functionPlants.FirstOrDefault(m => m.FunPlant.ToLower() == plantName.ToLower().Trim());
                if (hasItem != null)
                {
                    System_FunPlant_UID = hasItem.System_FunPlant_UID;
                }
                else
                {
                    //跳出循环
                    errorInfo = string.Format("厂别[{0}]输入不正确", plantName);
                    return(errorInfo);
                }


                Product_Stage            = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "阶层")].Value);
                Color                    = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "颜色")].Value) ?? string.Empty;
                Process_Desc             = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "工站說明")].Value);
                Rework_Setting           = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "返工设定")].Value);
                RelatedRepairBingdingSeq = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "对应修复站点")].Value);
                WIP            = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "WIP")].Value);
                NullWip        = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "不可用WIP")].Value);
                Current_WH_QTY = Convert.ToInt32(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "当前库存数")].Value);

                string Data_Source         = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "数据来源")].Value);
                var    Is_Synchronous      = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "是否同步")].Value);
                bool   bool_Is_Synchronous = false;
                try
                {
                    bool_Is_Synchronous = Convert.ToBoolean(Is_Synchronous == "Y" ? true : false);
                }
                catch
                {
                    errorInfo = string.Format("第{0}行是否同步[{1}]输入错误,请输入Y或N", i, Is_Synchronous);
                    return(errorInfo);
                }

                if (!string.IsNullOrEmpty(Rework_Setting) && Rework_Setting.ToLower() == "rework")
                {
                    if (string.IsNullOrWhiteSpace(RelatedRepairBingdingSeq))
                    {
                        errorInfo = string.Format("返工设定为Rework时,第[{0}]行对应修复站点不能为空", i);
                        return(errorInfo);
                    }

                    var ids       = RelatedRepairBingdingSeq.Split(',').ToList();
                    var intIdList = ids.Select <string, int>(x => Convert.ToInt32(x));
                    //把所有id都添加进队列里面后面一起判断
                    idList.AddRange(intIdList);
                }

                //检测站点赋值
                var CheckTemp = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, ExcelHelper.GetColumnIndex(propertiesContent, "检测设定")].Value);
                if (!string.IsNullOrWhiteSpace(CheckTemp))
                {
                    CheckTemp = CheckTemp.Trim();
                }

                switch (CheckTemp)
                {
                case StructConstants.IsQAProcessType.InspectText:     //IPQC全检
                    Check_Setting = StructConstants.IsQAProcessType.InspectKey;
                    break;

                case StructConstants.IsQAProcessType.PollingText:     //IPQC巡检
                    Check_Setting = StructConstants.IsQAProcessType.PollingKey;
                    break;

                case StructConstants.IsQAProcessType.InspectOQCText:     //OQC检测
                    Check_Setting = StructConstants.IsQAProcessType.InspectOQCKey;
                    break;

                case StructConstants.IsQAProcessType.InspectAssembleText:     //组装检测
                    Check_Setting = StructConstants.IsQAProcessType.InspectAssembleKey;
                    break;

                case StructConstants.IsQAProcessType.AssembleOQCText:     //组装&OQC检测
                    Check_Setting = StructConstants.IsQAProcessType.AssembleOQCKey;
                    break;

                default:
                    Check_Setting = string.Empty;
                    break;
                }

                #region 添加FlowChartDetail

                FlowChartImportDetailDTO detailDTOItem    = new FlowChartImportDetailDTO();
                FlowChartDetailDTO       newDetailDtoItem = new FlowChartDetailDTO()
                {
                    FlowChart_Master_UID = newMaster.FlowChart_Master_UID,
                    System_FunPlant_UID  = System_FunPlant_UID,
                    Binding_Seq          = Binding_Seq,
                    Process_Seq          = Process_Seq.ToString(),
                    DRI                       = DRI,
                    Place                     = Place,
                    Location_Flag             = (Location_Flag == "Y" || Location_Flag == "y") ? true : false,
                    Process                   = Process,
                    Product_Stage             = Product_Stage,
                    Color                     = Color,
                    Process_Desc              = Process_Desc,
                    FlowChart_Version_Comment = FlowChart_Version_Comment,
                    Rework_Flag               = Rework_Setting,
                    IsQAProcess               = Check_Setting,
                    Modified_UID              = newMaster.Modified_UID,
                    Modified_Date             = newMaster.Modified_Date,
                    BeginTime                 = DateTime.Now,
                    //存到临时表里面的数据所以要加1,存到正式表里面的数据不用加1
                    FlowChart_Version = isEdit ? newMaster.FlowChart_Version + 1 : newMaster.FlowChart_Version,
                    WIP_QTY           = WIP,
                    NullWip           = NullWip,
                    Current_WH_QTY    = Current_WH_QTY,
                    Data_Source       = Data_Source,
                    Is_Synchronous    = bool_Is_Synchronous
                };
                if (Rework_Setting == "Rework")
                {
                    newDetailDtoItem.RelatedRepairBindingSeq = RelatedRepairBingdingSeq;
                }
                else
                {
                    newDetailDtoItem.RelatedRepairBindingSeq = null;
                }
                detailDTOItem.FlowChartDetailDTO = newDetailDtoItem;
                //detailDTOItem.FlowChartMgDataDTO = newMgDataDtoItem;
                detailDTOList.Add(detailDTOItem);
                #endregion
                //行数加1
                realTotalRows++;
            }

            var bindingSeqCount = detailDTOList.GroupBy(m => m.FlowChartDetailDTO.Binding_Seq).Select(m => m.Key).Count();
            //var processSeqCount = detailDTOList.GroupBy(m => m.FlowChartDetailDTO.Process_Seq).Select(m => m.Key).Count();
            var rowCount = realTotalRows;
            if (bindingSeqCount != rowCount)
            {
                errorInfo = "绑定序号有重复项,请修改";
                return(errorInfo);
            }

            //判断设定的返工信息是否正确
            var bindSeqList = detailDTOList.Select(m => m.FlowChartDetailDTO.Binding_Seq).ToList();
            var notExistId  = idList.Distinct().ToList().Except(bindSeqList).ToList();
            if (notExistId.Count() > 0)
            {
                errorInfo = string.Format("对应修复站点的绑定序号:{0},设定有问题", notExistId.First());
                return(errorInfo);
            }
            return(errorInfo);
        }