天津投入产出系统后端
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.

113 lines
3.8 KiB

8 months ago
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>
5 months ago
[RoutePrefix("api/Machine")]
8 months ago
public class MachineController : ApiController
{
5 months ago
8 months ago
/// <summary>
/// 点检录入
/// </summary>
/// <returns></returns>
5 months ago
8 months ago
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")
{
7 months ago
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;
}
8 months ago
}
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
{
7 months ago
if (resObj.dataList[i].SelectValue == "4")
t.MValue = "停机状态";
else
t.MValue = resObj.dataList[i].SelectValue;
8 months ago
}
}
var sqlScript = $"INSERT INTO [dbo].[T_MD_PutMachineValueZhusu] ([PID], [MachineCode], [Name], [Type], [MValue], [Group], [UserName], [CreateData], [Remark1], [Remark2], [Remark3], [PValue]) VALUES (" +
5 months ago
$"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}');";
8 months ago
SqlData.InsertWare(sqlScript);
}
var Response = new Response();
return Ok(Response);
}
}
}