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 WareHouseController : ApiController
{
//T_MD_RawMaterial 投料信息
//T_MD_BUCKETINFO 料筒信息
//T_MD_BucketMaterial 料筒绑定
//T_MD_BucketMaterialClass 零件号绑定
[HttpGet]
public Response IsPass(string BucketCode, string RawMaterial)
{
var result = new Response();
var sqlScript = $"select * from T_MD_BucketMaterial where BucketCode = '{BucketCode}' and RawMaterial = '{RawMaterial}' and IsCheck = '0' ";
DataSet dataSet = SqlHelper.ExecuteDataset(Config.maindbConnectionString, CommandType.Text, sqlScript);
if (dataSet.Tables[0].Rows.Count <= 0)
{
result.Code = 201;
result.Message = "料筒与原料不符!";
}
return result;
}
// {"batchCode": "20240407",
// "bucketCode": "1500T-9",
// "createTime": "2024-04-07 14:43:47",
// "id": 1,
// "itemCode": "I01022501",
// "planNumber": "DP20230109004",
// "referenceCode": "123",
// "supplierCode": "001",
// "weight": "10"
//}
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_RawMaterial] ([PID], [BucketCode], [PartCode], [BatchCode], [SerialCode], [IsCheck], [CREATEUSER], [CREATEDATE], [planNumber], [supplierCode], [weight]) VALUES" +
$" ('{Guid.NewGuid()}', '{resObj.bucketCode}', '{resObj.itemCode}', '{resObj.batchCode}', '{resObj.referenceCode}', '0', '{resObj.id}', '{DateTime.Now}', '{resObj.planNumber}', '{resObj.supplierCode}', '{resObj.weight}');";
SqlData.InsertWare(sql);
var Response = new Response();
return Ok(Response);
}
}
}