天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

112 lines
3.8 KiB

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;
namespace WebAPI.Controllers
{
/// <summary>
/// 泡沫、注塑点检
/// </summary>
[RoutePrefix("api/Machine")]
public class MachineController : ApiController
{
/// <summary>
/// 点检录入
/// </summary>
/// <returns></returns>
public async Task<IHttpActionResult> InsertZhusu()
{
var request = await this.Request.Content.ReadAsStringAsync();
var requeststr = request.Replace("\r", "").Replace("\n", "");
var resObj = JsonHelper.Instance.JsonToObj<ReceiveMachine>(requeststr);
var group = "";//班次
switch (resObj.groupValue)
{
case "1":
group = "三班";
break;
case "2":
group = "白班";
break;
case "3":
group = "二班";
break;
}
var item = resObj.dataList[resObj.dataList.Count - 1];
for (var i = 0; i < resObj.dataList.Count - 1; i++)
{
var t = new MachineValue();
t.UserName = resObj.id;
t.MachineCode = resObj.dataList[i].PID;
t.Name = resObj.dataList[i].Content;
t.Type = resObj.dataList[i].Type;
t.Group = group;
t.UserName = resObj.id;
if (resObj.dataList[i].Type == "3")
{
if (resObj.dataList[i].SelectValue == "4")
{
t.MValue = "停机状态";
t.PValue = "停机状态";
}
else
{
t.MValue = resObj.dataList[i].putMachine[0].SelectName;
t.PValue = resObj.dataList[i].putMachine[1].SelectName;
}
}
else
{
if (resObj.dataList[i].Type == "1")
{
switch (resObj.dataList[i].SelectValue)
{
case "1":
t.MValue = "状态良好";
break;
case "2":
t.MValue = "正在处理";
break;
case "3":
t.MValue = "状态不好或损毁";
break;
case "4":
t.MValue = "停机状态";
break;
}
}
else
{
if (resObj.dataList[i].SelectValue == "4")
t.MValue = "停机状态";
else
t.MValue = resObj.dataList[i].SelectValue;
}
}
var sqlScript = $"INSERT INTO [dbo].[T_MD_PutMachineValueZhusu] ([PID], [MachineCode], [Name], [Type], [MValue], [Group], [UserName], [CreateData], [Remark1], [Remark2], [Remark3], [PValue]) VALUES (" +
$"N'{Guid.NewGuid()}', N'{t.MachineCode}', N'{t.Name}', N'{t.Type}', N'{t.MValue}', N'{t.Group}', N'{t.UserName}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff")}', {t.ProductCode}, NULL, NULL, N'{t.PValue}');";
SqlData.InsertWare(sqlScript);
}
var Response = new Response();
return Ok(Response);
}
}
}