Exemplo n.º 1
0
        public ActionResult SavePart(FormNcrPart part, string abnormalImage, string abnormalAttribution)
        {
            if (!string.IsNullOrEmpty(abnormalImage) || !string.IsNullOrEmpty(abnormalAttribution))
            {
                var upNcrMain = new BaseServices <FormNcr>();
                //保存描述
                var ncrMain = upNcrMain.Single(c => c.FormNo == part.ParentFormNo);
                ncrMain.AbnormalImage       = abnormalImage;
                ncrMain.AbnormalAttribution = abnormalAttribution;
                upNcrMain.UpdateEntity(ncrMain);
            }


            //return Content("111");
            string empNo = ManageProvider.Provider.Current().UserId;
            Dictionary <string, object> dictionary = Request.Form.Cast <object>().ToDictionary <object, string, object>(para => para.ToString(), para => Request.Form[para.ToString()]);

            var formId    = int.Parse(dictionary["formid"].ToString());
            var employees = new Applying().GetSignListByFormId(dictionary, formId, empNo);
            var form      = new Form
            {
                FormNo      = new Applying().CreateFormNo(new object()),
                FormId      = formId,
                CreateEmpNo = empNo,
                CreateTime  = DateTime.Now,
                SignPath    = string.Join(",", employees.Select(c => c.EmpNo)) + ",",
                FormStatus  = 0,
                IsEmergents = true,
            };



            FormNcrPart partA = new FormNcrPart()
            {
                Mark = part.Mark, ReplyType = formId, ParentFormNo = part.ParentFormNo, Reviewer = empNo, ReviewTime = DateTime.Now
            };
            var result = new F <FormNcrPart>().SaveData(new List <FormNcrPart>()
            {
                partA
            }, form);


            //送签
            if (!result)
            {
                return(Link.ErrorBy(new Exception("数据更新失败,请检查填写是否完整"), this.GetType()));
            }
            new Applying().Send(form.FormNo, empNo);


            var daiqian = new BaseServices <FormSign>().LoadEntities(c => c.FormNo == form.FormNo).Last();
            var signed  = new Signing().Agree(daiqian.FormNo, daiqian.RowId, daiqian.SignEmpNo);

            Console.Write(signed);

            return(Content("success"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据Route和提交人生成表单签核人
        /// </summary>
        /// <param name="route"></param>
        /// <param name="empNo"></param>
        /// <returns></returns>
        private static List <BaseEmployee> GenerateSignList(IList <string> route, string empNo)
        {
            var section1 = route[0];
            var section2 = route[1];
            var section3 = route[2];

            //最终签核人
            var signList = new List <BaseEmployee>();

            var employees = new BaseServices <BaseEmployee>().LoadEntities(c => c.IsDimission != 0).ToList();

            var my = DataFactory.Database().FindEntity <BaseEmployee>(empNo);

            //该设定为自已签核
            if (_formType.IsMyself)
            {
                signList.Add(my);
                return(signList);
            }



            var patten = new Regex("\\d{7}");

            //部门内成员
            if (!string.IsNullOrEmpty(section1))
            {
                //T,S,P,M,1109001
                var applypath = section1.ToUpper().Split(',').ToList().RemoveStringNullOrEmpty();

                foreach (var c in applypath)
                {
                    if (patten.IsMatch(c))
                    {
                        signList.Add(employees.Single(k => k.EmpNo == c));
                    }
                    else
                    {
                        signList.Add(GetDepartmentTopOneByPosition(employees, my.DepartmentId, c));
                    }
                }
            }
            //部门外成员
            if (!string.IsNullOrEmpty(section2))
            {
                //HRS00:M,//M0000:M,//HRS00:P

                foreach (var c in section2.ToUpper().Split(',').ToList().RemoveStringNullOrEmpty())
                {
                    if (patten.IsMatch(c))
                    {
                        signList.Add(employees.Single(k => k.EmpNo == c));
                    }
                    else
                    {
                        signList.Add(GetDepartmentTopOneByPosition(employees, c.Split(':')[0], c.Split(':')[1]));
                    }
                }
            }
            //审核部门成员
            if (!string.IsNullOrEmpty(section3))
            {
                //M,S,P,1109001

                var operatorpath = section3.ToUpper().Split(',').ToList().RemoveStringNullOrEmpty();

                //处理人所属部门
                var departCode = employees.Single(x => x.EmpNo == operatorpath.Last()).DepartmentId;

                foreach (var c in operatorpath)
                {
                    if (patten.IsMatch(c))
                    {
                        signList.Add(employees.Single(k => k.EmpNo == c));
                    }
                    else
                    {
                        signList.Add(GetDepartmentTopOneByPosition(employees, departCode, c));
                    }
                }


                // operatorpath.ForEach(c => signList.Add(patten.IsMatch(c) ? employees.Single(k => k.EmpNo == c) : GetDepartmentTopOneByPosition(employees, departCode, c)));
            }

            signList.RemoveAll(c => c == null);
            return(signList);
        }
Exemplo n.º 3
0
        public int OldImport(DataSet ds)
        {
            var customers = new TpaModule.TpaCustomerBll().GetList();
            var formTyps  = new BaseServices <FormType>().LoadEntities(c => true);

            DataTable dt          = ds.Tables[0];
            string    publishType = dt.ToString();


            int success = 0;

            foreach (var row in dt.Rows)
            {
                try
                {
                    string fileName = ((DataRow)(row)).ItemArray[0].ToString();
                    string ver      = ((DataRow)(row)).ItemArray[1].ToString();
                    int    pageSize = int.Parse(((DataRow)(row)).ItemArray[2].ToString());
                    string filePath = @"\\192.168.0.4\Minicut\公司文件\文控\图纸电子档\勿动\" + ((DataRow)(row)).ItemArray[3] + ".pdf";

                    string       reason      = ((DataRow)(row)).ItemArray[4].ToString();
                    DateTime     publishDate = DateTime.Parse(((DataRow)(row)).ItemArray[5].ToString());
                    const string publishEmp  = "1109004";
                    bool         isPass      = int.Parse(((DataRow)(row)).ItemArray[7].ToString()) == 1;

                    string fileType = Path.GetExtension(filePath);


                    Guid fileGroup = Guid.NewGuid();
                    using (var fs = new FileStream(filePath, FileMode.Open))
                    {
                        var md5 = DirFileHelper.GetMd5StringByStream(fs);

                        string targetPath = Path.GetFullPath(BaseHelper.UpPath);

                        //将文什上传至文档临时目录
                        BaseHelper.CopyFile(filePath, targetPath + md5);
                        using (var context = ContextFactory.ContextHelper)
                        {
                            //组建文件群组
                            context.FileGroups.Add(new FileGroup()
                            {
                                GroupGuid   = fileGroup,
                                CreateTime  = DateTime.Now,
                                CreateEmpNo = "1109001"
                            });

                            //上传文件

                            if (!context.Fileses.Any(c => c.Md5 == md5))
                            {
                                context.Fileses.Add(new Files()
                                {
                                    Md5         = md5,
                                    FileName    = fileName,
                                    FileType    = fileType,
                                    ContentType = "application/pdf",
                                });
                            }

                            context.FilesFileGroups.AddRange(new List <FilesFileGroup> {
                                new FilesFileGroup()
                                {
                                    Md5 = md5, GroupGuid = fileGroup
                                }
                            });
                            context.SaveChanges();
                        }


                        //组建文件关系
                    }

                    int formId = formTyps.Single(c => c.FormName.Contains(publishType)).FormId;

                    //创建表单内容
                    var form = new Form()
                    {
                        FormNo      = new Applying().CreateFormNo(new object()),
                        FormId      = formId,
                        CreateEmpNo = "1109001",
                        CreateTime  = publishDate,
                        SignPath    = null,
                        FormStatus  = (int)Form.StatusEnum.签核完成,
                        IsEmergents = false,
                        CloseTime   = DateTime.Now
                    };

                    //生成表单
                    new BaseServices <Form>().AddEntity(form);

                    #region insert
                    //生成表单详细页
                    switch (publishType)
                    {
                    case "BOM":
                        new BaseServices <FormDrawingsBom>().AddEntity(new FormDrawingsBom()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            FileCode    = ((DataRow)(row)).ItemArray[12].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[13].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "ECN":
                        new BaseServices <FormDrawingsEcn>().AddEntity(new FormDrawingsEcn()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[10].ToString(),
                            EcnNo       = ((DataRow)(row)).ItemArray[11].ToString(),
                            PublishEmp  = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "SOP":
                        new BaseServices <FormDrawingsSop>().AddEntity(new FormDrawingsSop()
                        {
                            CustomerNo = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo = ((DataRow)(row)).ItemArray[9].ToString(),
                            Tag        = ((DataRow)(row)).ItemArray[10].ToString(),
                            Author     = ((DataRow)(row)).ItemArray[11].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "包装工艺卡":
                        new BaseServices <FormDrawingsPackage>().AddEntity(new FormDrawingsPackage()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[10].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[11].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "工艺流程图":
                        new BaseServices <FormDrawingsProcess>().AddEntity(new FormDrawingsProcess()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "检规指导书":
                        new BaseServices <FormDrawingsFqc>().AddEntity(new FormDrawingsFqc()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[12].ToString(),


                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "客户图纸":
                        new BaseServices <FormDrawingsCustomer>().AddEntity(new FormDrawingsCustomer()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            ManagerHead = ((DataRow)(row)).ItemArray[12].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "内部图纸":
                        new BaseServices <FormDrawingsInside>().AddEntity(new FormDrawingsInside()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "内部型材图":
                        new BaseServices <FormDrawingsProfile>().AddEntity(new FormDrawingsProfile()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProfileNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "外来文件":
                        new BaseServices <FormDrawingsExternal>().AddEntity(new FormDrawingsExternal()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            FileName    = ((DataRow)(row)).ItemArray[9].ToString(),
                            FileCode    = ((DataRow)(row)).ItemArray[10].ToString(),
                            MinicutCode = ((DataRow)(row)).ItemArray[11].ToString(),
                            ReciveEmpNo = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "控制计划":
                        new BaseServices <FormDrawingsControlPlan>().AddEntity(new FormDrawingsControlPlan()
                        {
                            CustomerNo = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            Author     = ((DataRow)(row)).ItemArray[10].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;
                    }
                    #endregion



                    //发行
                    if (this.Published(form.FormNo, 0, publishEmp, publishDate, isPass))
                    {
                        success++;
                    }
                }
                catch (Exception exception)
                {
                    return(Link.ErrorBy(new Exception($"成功导入{success}:Error:{exception.Message}"), this.GetType()));
                }
            }

            return(success);
        }