using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Web.Http; using WebAPI.App_Start; using WebAPI.Models; using Newtonsoft.Json.Converters; using QMAPP.MD.Entity.Bucket; namespace WebAPI.Controllers { /// /// 注塑投料 /// public class WareController : ApiController { /// /// 泡沫投料种类 /// /// /// /// [HttpGet] public Response> GetTypeList() { var result = new Response>(); var dic_list = new List(); var sqlScript = $"select * from T_MD_BucketMaterialClassPaomo where IsCheck = '0' "; DataSet dataSet = SqlHelper.ExecuteDataset(Config.maindbConnectionString, CommandType.Text, sqlScript); if (dataSet.Tables[0].Rows.Count >= 0) { foreach (DataRow row in dataSet.Tables[0].Rows) { var dic = new TypeList(); dic.Code = row["RawMaterial"].ToString(); dic.Name = row["MaterialName"].ToString(); dic_list.Add(dic); } } result.Result = dic_list; return result; } /// /// 泡沫投料 插入 /// /// //{"planNumber":"DP20230109004","materialName":"NBT催化剂3","materialCode":"C45050101","materialQty":"10","id":"admin","createTime":"2024-04-07 11:11:21"} 原料投入泡沫提交的参数这样可以吗 public async Task Insert() { var request = await this.Request.Content.ReadAsStringAsync(); var requeststr = request.Replace("\r", "").Replace("\n", ""); var resObj = JsonHelper.Instance.JsonToObj(requeststr); var sql = $"INSERT INTO [dbo].[T_MD_RawMaterialPaomo] ([PID], [planNumber], [materialName], [materialCode], [materialQty], [UserName], [CreateTime], [Remark1], [Remark2], [Remark3]) VALUES" + $" (N'{Guid.NewGuid()}', NULL, N'{resObj.materialName}', N'{resObj.materialCode}', N'{resObj.materialQty}', N'{resObj.id}', '{DateTime.Now}', NULL, NULL, NULL);"; SqlData.InsertWare(sql); var Response = new Response(); return Ok(Response); } } }