示例#1
0
        public IActionResult Update(MainContractUpdateDto parm)
        {
            var userinfo = _tokenManager.GetSessionInfo();

            if (_maincontractService.Any(m => m.PreContractID == parm.PreContractID && m.status >= 10020))
            {
                return(toResponse(StatusCodeType.Error, $"当前合同已经审批通过,不允许修改!"));
            }
            var contract = _maincontractService.GetId(parm.ID);

            if (contract == null || contract.deleted == 1)
            {
                return(toResponse(StatusCodeType.Error, "当前合同信息不存在"));
            }

            using (SqlSugarClient db = Core.DbContext.CurrentDB)
            {
                Core.DbContext.BeginTran();
                try
                {
                    //从 Dto 映射到 实体
                    _maincontractService.Update(m => m.ID == parm.ID, m => new Biz_MainContract()
                    {
                        ConcernExtent     = parm.ConcernExtent,
                        ConcernExtentName = parm.ConcernExtentName,
                        AuditPlanDate     = parm.AuditPlanDate,
                        JudgeReuqest      = parm.JudgeReuqest,
                        AuditPlanRequest  = parm.AuditPlanRequest,
                        AuditGroupRequest = parm.AuditGroupRequest,
                        DecisionRequest   = parm.DecisionRequest,
                        Remark            = parm.Remark,
                        UpdateID          = userinfo.ID,
                        UpdateName        = userinfo.UserName,
                        UpdateTime        = DateTime.Now
                    });
                    //添加合同关联项目信息
                    List <ContractItemVM> ItemList_update = parm.ContractItemList_update; //更新
                    List <ContractItemVM> ItemList_insert = parm.ContractItemList_insert; //插入
                    List <ContractItemVM> ItemList_delete = parm.ContractItemList_delete; //删除

                    //删除合同体系项目
                    string[] ids = ItemList_delete.Where(x => !string.IsNullOrEmpty(x.ID)).Select(x => x.ID).ToArray();
                    db.Updateable <Biz_ContractItem>().SetColumns(m => new Biz_ContractItem {
                        deleted = 1
                    }).Where(m => m.MainContractID == parm.ID && ids.Contains(m.ID)).ExecuteCommand();
                    if (ItemList_update != null) //更新列表
                    {
                        foreach (var Item in ItemList_update)
                        {
                            var    standard = db.Queryable <Abi_SysStandard>().First(m => m.ID == Item.ItemStandardID);
                            string itemno   = parm.ContractNo + standard.SysStandardNo;
                            db.Updateable <Biz_ContractItem>().SetColumns(m => new Biz_ContractItem()
                            {
                                ItemStandardID = Item.ItemStandardID,
                                ItemName       = Item.ItemName,
                                AuditTypeID    = Item.AuditTypeID,
                                AuditTypeName  = Item.AuditTypeName,
                                PropleNum      = Item.PropleNum,
                                ApplyRange     = Item.ApplyRange,
                                ApplyRangeEN   = Item.ApplyRangeEN,
                                OrganizationIn = Item.OrganizationIn,
                                ReevaluateNum  = Item.ReevaluateNum,
                                UpdateID       = userinfo.ID,
                                UpdateName     = userinfo.UserName,
                                UpdateTime     = DateTime.Now
                            }).Where(m => m.ID == Item.ID).ExecuteCommand();
                        }
                    }
                    if (ItemList_insert != null) //插入新数据
                    {
                        foreach (var Item in ItemList_insert)
                        {
                            Biz_ContractItem contractitem = new Biz_ContractItem();
                            contractitem.ID               = Guid.NewGuid().ToString();
                            contractitem.MainContractID   = parm.ID;
                            contractitem.ItemStandardID   = Item.ItemStandardID;   //标准ID
                            contractitem.ItemStandardCode = Item.ItemStandardCode; //标准code
                            contractitem.ItemName         = Item.ItemName;         //标准名称
                            contractitem.AuditTypeID      = Item.AuditTypeID;      //审核类型
                            contractitem.AuditTypeName    = Item.ItemName;         //审核类型名称
                            contractitem.PropleNum        = Item.PropleNum;        //体系人数
                            contractitem.ApplyRange       = Item.ApplyRange;       //申请范围
                            contractitem.ApplyRangeEN     = Item.ApplyRangeEN;     //申请范围英文
                            contractitem.OrganizationIn   = Item.OrganizationIn;   //是否机构转入
                            contractitem.ReevaluateNum    = Item.ReevaluateNum;    //复评次数
                            contractitem.CreateTime       = DateTime.Now;
                            contractitem.CreateID         = userinfo.ID;
                            contractitem.CreateName       = userinfo.UserName;
                            contractitem.deleted          = 0;

                            var standard = db.Queryable <Abi_SysStandard>().First(m => m.ID == Item.ItemStandardID);
                            contractitem.ContractItemNo = parm.ContractNo + standard.SysStandardNo;

                            db.Insertable <Biz_ContractItem>(contractitem).ExecuteCommand();
                        }
                    }
                    //添加合同多场所信息
                    List <FcsVM> FcsList_update = parm.ContractfcsList_update; //更新
                    List <FcsVM> FcsList_insert = parm.ContractfcsList_insert; //插入
                    List <FcsVM> FcsList_delete = parm.ContractfcsList_delete; //删除
                    //删除合同体系项目
                    string[] fcsids = FcsList_delete.Where(x => !string.IsNullOrEmpty(x.ID)).Select(x => x.ID).ToArray();
                    db.Deleteable <Biz_ContractFcs>().Where(m => m.MainContractID == parm.ID && fcsids.Contains(m.ID)).ExecuteCommand();
                    if (FcsList_update != null) //更新数据
                    {
                        foreach (var fcs in FcsList_update)
                        {
                            db.Updateable <Biz_ContractFcs>().SetColumns(m => new Biz_ContractFcs()
                            {
                                fcsID = fcs.fcsID
                            }).Where(m => m.ID == fcs.ID).ExecuteCommand();
                        }
                    }
                    if (FcsList_insert != null)
                    {
                        foreach (var fcs in FcsList_insert)
                        {
                            Biz_ContractFcs contractfcs = new Biz_ContractFcs();
                            contractfcs.ID             = Guid.NewGuid().ToString();
                            contractfcs.fcsID          = fcs.fcsID;
                            contractfcs.MainContractID = parm.ID;
                            contractfcs.CustomerID     = parm.CustomerID;
                            contractfcs.CreateTime     = DateTime.Now;
                            contractfcs.CreateID       = userinfo.ID;
                            contractfcs.CreateName     = userinfo.UserName;

                            db.Insertable <Biz_ContractFcs>(contractfcs).ExecuteCommand();
                        }
                    }
                    //评审附件
                    List <FileVM> FileList_update = parm.ContractFileList_update; //更新
                    List <FileVM> FileList_insert = parm.ContractFileList_insert; //插入
                    List <FileVM> FileList_delete = parm.ContractFileList_delete; //删除
                    //删除合同体系项目
                    string[] fileids = FileList_delete.Where(x => !string.IsNullOrEmpty(x.ID)).Select(x => x.ID).ToArray();
                    db.Deleteable <Biz_ContractFile>().Where(m => m.MainContractID == parm.ID && fileids.Contains(m.ID)).ExecuteCommand();
                    if (FileList_update != null)//更新
                    {
                        foreach (var file in FileList_update)
                        {
                            db.Updateable <Biz_ContractFile>().SetColumns(m => new Biz_ContractFile()
                            {
                                FileID   = file.FileID,
                                FileName = file.FileName,
                                Name     = file.FileName,
                            }).Where(m => m.ID == file.ID).ExecuteCommand();
                        }
                    }
                    if (FileList_insert != null) //插入
                    {
                        foreach (var file in FileList_insert)
                        {
                            Biz_ContractFile contractfile = new Biz_ContractFile();
                            contractfile.ID             = Guid.NewGuid().ToString();
                            contractfile.FileID         = file.FileID;
                            contractfile.FileName       = file.FileName;
                            contractfile.Name           = file.FileName;
                            contractfile.MainContractID = parm.ID;
                            contractfile.CustomerID     = parm.CustomerID;
                            contractfile.CreateTime     = DateTime.Now;
                            contractfile.CreateID       = userinfo.ID;
                            contractfile.CreateName     = userinfo.UserName;

                            db.Insertable <Biz_ContractFile>(contractfile).ExecuteCommand();
                        }
                    }
                    //更新状态为已登记
                    var i = db.Updateable <Biz_MainContract>()
                            .SetColumns(it => new Biz_MainContract()
                    {
                        UpdateTime = DateTime.Now, UpdateID = userinfo.ID, UpdateName = userinfo.UserName
                    })
                            .Where(it => it.ID == parm.ID).ExecuteCommand();

                    Core.DbContext.CommitTran();

                    return(toResponse(parm.ID));
                }
                catch (Exception ex)
                {
                    Core.DbContext.RollbackTran();
                    return(toResponse(StatusCodeType.Error, ex.Message));
                }
            }
        }
示例#2
0
        public IActionResult Apply([FromBody] MainContractCreateDto parm)
        {
            var userinfo = _tokenManager.GetSessionInfo();

            if (!_precontractService.Any(m => m.ID == parm.PreContractID && m.Status == 0))
            {
                return(toResponse(StatusCodeType.Error, $"不存在当前未登记OA合同,请核对!"));
            }
            if (_maincontractService.Any(m => m.PreContractID == parm.PreContractID && m.deleted == 0))
            {
                using (SqlSugarClient db = Core.DbContext.Current)
                {
                    //更新状态为已登记
                    var i = db.Updateable <Biz_PreContract>()
                            .SetColumns(it => new Biz_PreContract()
                    {
                        Status = 1, RegisterTime = DateTime.Now, RegisterID = userinfo.ID, RegisterName = userinfo.UserName
                    })
                            .Where(it => it.ID == parm.PreContractID).ExecuteCommand();
                }
                return(toResponse(StatusCodeType.Error, $"当前合同已经受理,不能重复!"));
            }


            using (SqlSugarClient db = Core.DbContext.CurrentDB)
            {
                Core.DbContext.BeginTran();
                try
                {
                    //从 Dto 映射到 实体
                    var options = parm.Adapt <Biz_MainContract>().ToCreate(_tokenManager.GetSessionInfo());
                    options.status = 10000;
                    if (db.Insertable <Biz_MainContract>(options).ExecuteCommand() == 0)
                    {
                        return(toResponse(StatusCodeType.Error, "受理失败,不能重复!"));
                    }
                    //添加合同关联项目信息
                    List <ContractItemVM> ItemList = parm.ContractItemList_insert;
                    if (ItemList != null)
                    {
                        foreach (var Item in ItemList)
                        {
                            Biz_ContractItem contractitem = new Biz_ContractItem();
                            contractitem.ID               = Guid.NewGuid().ToString();
                            contractitem.MainContractID   = options.ID;
                            contractitem.ItemStandardID   = Item.ItemStandardID;   //标准ID
                            contractitem.ItemStandardCode = Item.ItemStandardCode; //标准code
                            contractitem.ItemName         = Item.ItemName;         //标准名称
                            contractitem.AuditTypeID      = Item.AuditTypeID;      //审核类型
                            contractitem.AuditTypeName    = Item.AuditTypeName;    //审核类型名称
                            contractitem.PropleNum        = Item.PropleNum;        //体系人数
                            contractitem.ApplyRange       = Item.ApplyRange;       //申请范围
                            contractitem.ApplyRangeEN     = Item.ApplyRangeEN;     //申请范围英文
                            contractitem.OrganizationIn   = Item.OrganizationIn;   //是否机构转入
                            contractitem.ReevaluateNum    = Item.ReevaluateNum;
                            contractitem.CreateTime       = DateTime.Now;
                            contractitem.CreateID         = userinfo.ID;
                            contractitem.CreateName       = userinfo.UserName;
                            contractitem.deleted          = 0;

                            var standard = db.Queryable <Abi_SysStandard>().First(m => m.AutoID == int.Parse(Item.ItemStandardID));
                            contractitem.ContractItemNo = options.ContractNo + standard.SysStandardNo;

                            db.Insertable <Biz_ContractItem>(contractitem).ExecuteCommand();
                        }
                    }
                    //添加合同多场所信息
                    List <FcsVM> FcsList = parm.ContractfcsList_insert;
                    if (FcsList != null)
                    {
                        foreach (var fcs in FcsList)
                        {
                            Biz_ContractFcs contractfcs = new Biz_ContractFcs();
                            contractfcs.ID             = Guid.NewGuid().ToString();
                            contractfcs.fcsID          = fcs.fcsID;
                            contractfcs.MainContractID = options.ID;
                            contractfcs.CustomerID     = options.CustomerID;
                            contractfcs.CreateTime     = DateTime.Now;
                            contractfcs.CreateID       = userinfo.ID;
                            contractfcs.CreateName     = userinfo.UserName;

                            db.Insertable <Biz_ContractFcs>(contractfcs).ExecuteCommand();
                        }
                    }
                    //评审附件
                    List <FileVM> FileList = parm.ContractFileList_insert;
                    if (FileList != null)
                    {
                        foreach (var file in FileList)
                        {
                            Biz_ContractFile contractfile = new Biz_ContractFile();
                            contractfile.ID             = Guid.NewGuid().ToString();
                            contractfile.FileID         = file.FileID;
                            contractfile.FileName       = file.FileName;
                            contractfile.Name           = file.FileName;
                            contractfile.MainContractID = options.ID;
                            contractfile.CustomerID     = options.CustomerID;
                            contractfile.CreateTime     = DateTime.Now;
                            contractfile.CreateID       = userinfo.ID;
                            contractfile.CreateName     = userinfo.UserName;

                            db.Insertable <Biz_ContractFile>(contractfile).ExecuteCommand();
                        }
                    }
                    //更新状态为已登记
                    var i = db.Updateable <Biz_PreContract>()
                            .SetColumns(it => new Biz_PreContract()
                    {
                        Status = 1, RegisterTime = DateTime.Now, RegisterID = userinfo.ID, RegisterName = userinfo.UserName
                    })
                            .Where(it => it.ID == options.PreContractID).ExecuteCommand();

                    Core.DbContext.CommitTran();

                    return(toResponse(options.ID));
                }
                catch (Exception ex)
                {
                    Core.DbContext.RollbackTran();
                    return(toResponse(StatusCodeType.Error, ex.Message));
                }
            }
        }