// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 // // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! using Admin.NET.Core; using Admin.NET.Core.Service; using Furion.DependencyInjection; using Furion.DynamicApiController; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Vistar.Application.Const; using Vistar.Application.Entity; using Vistar.Application.Service.SapOpenInterface.Dto; using Vistar.Application.SolidWorksManageService.Dto; using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionResponse.Types; namespace Vistar.Application.Service.SapOpenInterface; /// /// 开放接口给Sap /// [ApiDescriptionSettings(ApplicationConst.GroupName, Name = "SapOpenInterface", Order = 100)] public class SapOpenInterfaceService : IDynamicApiController, ITransient { public SqlSugarRepository _obj132Rep; public SolidWorksManageService.SolidWorksManageService _solidWorksManageService; public SapOpenInterfaceService(SqlSugarRepository obj132Rep, SolidWorksManageService.SolidWorksManageService solidWorksManageService) { _obj132Rep = obj132Rep; _solidWorksManageService = solidWorksManageService; } /// /// SAP创建、修改客户档案 /// /// /// [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] [ApiDescriptionSettings(Name = "CreateClientRecord"), HttpPost] [DisplayName("SAP创建、修改客户档案")] public async Task CreateClientRecord(CreateClientRecordInput input) { var response = new ManageResponse(); if (string.IsNullOrWhiteSpace(input._System_objNBS) || string.IsNullOrWhiteSpace(input._System_objDescription)) { response.Success = true; response.Message = "请输入必填字段"; return response; } //判断是否存在客户记录 var clientExists = await _obj132Rep.AsQueryable().AnyAsync(x => x._System_objNBS == input._System_objNBS && x.deleted == false); if (clientExists == false) { var fieldList = new List(); fieldList.Add(new Field { key = "_System_objNBS", value = input._System_objNBS }); fieldList.Add(new Field { key = "_System_objDescription", value = input._System_objDescription }); if (!string.IsNullOrWhiteSpace(input.fld004808)) { fieldList.Add(new Field { key = "fld004808", value = input.fld004808 }); } if (!string.IsNullOrWhiteSpace(input.fld004950)) { fieldList.Add(new Field { key = "fld004950", value = input.fld004950 }); } var data = new CreateRecordInput { object_id = 132, field_group_id = 422, fields = fieldList }; response = await _solidWorksManageService.CreateRecord(data); return response; } else if (clientExists == true) { var updateable = await _obj132Rep.AsUpdateable() .SetColumns(it => new Obj132 { _System_ObjDescription = input._System_objDescription, fld004808 = input.fld004808, fld004950 = input.fld004950 }) .Where(x => x._System_objNBS == input._System_objNBS && x.deleted == false) .ExecuteCommandHasChangeAsync(); response.Success = true; response.Message = updateable ? "修改成功" : "修改失败"; return response; } return response; } }