Пример #1
0
        public IActionResult Update([FromBody] FactoryUpdateDto parm)
        {
            if (_factoryService.Any(m => m.FactoryNo == parm.FactoryNo && m.ID != parm.ID))
            {
                return(toResponse(StatusCodeType.Error, $"更新工厂编码 {parm.FactoryNo} 已存在,不能重复!"));
            }

            try
            {
                _unitOfWork.BeginTran();

                var userSession = _tokenManager.GetSessionInfo();

                var response = _factoryService.Update(m => m.ID == parm.ID, m => new Base_Factory()
                {
                    FactoryNo   = parm.FactoryNo,
                    FactoryName = parm.FactoryName,
                    Enable      = parm.Enable,
                    Remark      = parm.Remark,
                    UpdateID    = userSession.UserID,
                    UpdateName  = userSession.UserName,
                    UpdateTime  = DateTime.Now
                });

                //删除关系表
                _dataRelationService.Delete(m => m.Form == parm.ID && m.Type == DataRelationType.Factory_To_Company.ToString());

                //插入关系表
                _dataRelationService.Add(new Sys_DataRelation
                {
                    ID   = GetGUID,
                    Form = parm.ID,
                    To   = parm.CompanyUID,
                    Type = DataRelationType.Factory_To_Company.ToString()
                });

                _unitOfWork.CommitTran();

                return(toResponse(response));
            }
            catch (Exception)
            {
                _unitOfWork.RollbackTran();
                throw;
            }
        }
Пример #2
0
        public IActionResult Update([FromBody] ProductProcessUpdateDto parm)
        {
            if (_processService.Any(m => m.ProcessNo == parm.ProcessNo && m.ID != parm.ID))
            {
                return(toResponse(StatusCodeType.Error, $"添加工序编码 {parm.ProcessNo} 已存在,不能重复!"));
            }

            try
            {
                _dataRelationService.BeginTran();

                var userSession = _tokenManager.GetSessionInfo();

                var response = _processService.Update(m => m.ID == parm.ID, m => new Base_ProductProcess()
                {
                    ProcessNo   = parm.ProcessNo,
                    ProcessName = parm.ProcessName,
                    Enable      = parm.Enable,
                    Remark      = parm.Remark,
                    UpdateID    = userSession.UserID,
                    UpdateName  = userSession.UserName,
                    UpdateTime  = DateTime.Now
                });

                //删除关系表
                _dataRelationService.Delete(m => m.Form == parm.ID && m.Type == DataRelationType.Process_To_WorkShop.ToString());

                //插入关系表
                _dataRelationService.Add(new Sys_DataRelation
                {
                    ID   = GetGUID,
                    Form = parm.ID,
                    To   = parm.WorkShopUID,
                    Type = DataRelationType.Process_To_WorkShop.ToString()
                });

                _dataRelationService.CommitTran();

                return(toResponse(response));
            }
            catch (Exception ex)
            {
                _dataRelationService.RollbackTran();
                throw ex;
            }
        }
Пример #3
0
        public IActionResult Update([FromBody] EquipmentUpdateDto parm)
        {
            if (_equipmentService.Any(m => m.EquipNo == parm.EquipNo && m.ID != parm.ID))
            {
                return(toResponse(StatusCodeType.Error, $"添加机台编码 {parm.EquipNo} 已存在,不能重复!"));
            }

            try
            {
                _dataRelationService.BeginTran();

                var userSession = _tokenManager.GetSessionInfo();

                var response = _equipmentService.Update(m => m.ID == parm.ID, m => new Base_Equipment()
                {
                    EquipNo    = parm.EquipNo,
                    EquipName  = parm.EquipName,
                    Enable     = parm.Enable,
                    Remark     = parm.Remark,
                    UpdateID   = userSession.UserID,
                    UpdateName = userSession.UserName,
                    UpdateTime = DateTime.Now
                });

                //删除关系表
                _dataRelationService.Delete(m => m.Form == parm.ID && m.Type == DataRelationType.Equipment_To_Line.ToString());

                //插入关系表
                _dataRelationService.Add(new Sys_DataRelation
                {
                    ID   = GetGUID,
                    Form = parm.ID,
                    To   = parm.LineUID,
                    Type = DataRelationType.Equipment_To_Line.ToString()
                });

                _dataRelationService.CommitTran();

                return(toResponse(response));
            }
            catch (Exception)
            {
                _dataRelationService.RollbackTran();
                throw;
            }
        }