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.
204 lines
7.1 KiB
204 lines
7.1 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WcfControlMonitorLib;
|
|
using CommLayerFactory;
|
|
using ICommLayer;
|
|
|
|
namespace WcfControlMonitorWebLib.Controllers
|
|
{
|
|
[ApiController, Route("api/stationStatus")]
|
|
public class StationStatusController : ControllerBase
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
DataView dw;
|
|
CCommonFunction ccf = new CCommonFunction();
|
|
ISendDeviceOrder sdo;
|
|
|
|
[HttpGet]
|
|
public IActionResult Get(
|
|
[FromQuery] string id,
|
|
[FromQuery] string checkStation,
|
|
[FromQuery] string stationModel,
|
|
[FromQuery] string wareHouse,
|
|
[FromQuery] string stationType,
|
|
[FromQuery] string sort,
|
|
[FromQuery] int? offset,
|
|
[FromQuery] int? limit)
|
|
{
|
|
if (offset == null)
|
|
{
|
|
offset = 0;
|
|
}
|
|
if (limit == null)
|
|
{
|
|
limit = 30;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
var where = "1=1";
|
|
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
where = $"{where} AND F_Station_Code = '{id}'";
|
|
}
|
|
if (!string.IsNullOrEmpty(checkStation))
|
|
{
|
|
where = $"{where} AND F_CheckStation = '{checkStation}'";
|
|
}
|
|
if (!string.IsNullOrEmpty(stationModel))
|
|
{
|
|
where = $"{where} AND F_Station_Model = {stationModel}";
|
|
}
|
|
if (!string.IsNullOrEmpty(wareHouse))
|
|
{
|
|
where = $"{where} AND F_WareHouse = {wareHouse}";
|
|
}
|
|
if (!string.IsNullOrEmpty(stationType))
|
|
{
|
|
string stationTypeDes = "1";
|
|
if (stationType == "出库") { stationTypeDes = "2"; }
|
|
where = $"{where} AND F_Station_Type = {stationTypeDes}";
|
|
}
|
|
sql.Append("select F_Station_Code,F_CheckStation,F_Station_Model,F_WareHouse ,F_Station_Type from T_Base_Station_Model where " + where);
|
|
dw = CStaticClass.dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dw.Count > 0)
|
|
{
|
|
var items = new dynamic[dw.Count];
|
|
for (int i = 0; i < dw.Count; i++)
|
|
{
|
|
string stationTypeDes = "入库";
|
|
if (Convert.ToInt32(dw[i]["F_Station_Type"]) == 2) { stationTypeDes = "出库"; }
|
|
items[i] = new
|
|
{
|
|
id = Convert.ToInt32(dw[i]["F_Station_Code"]),
|
|
checkStation = Convert.ToString(dw[i]["F_CheckStation"]),
|
|
stationModel = Convert.ToInt32(dw[i]["F_Station_Model"]),
|
|
wareHouse = Convert.ToInt32(dw[i]["F_WareHouse"]),
|
|
stationType = stationTypeDes
|
|
};
|
|
}
|
|
return Ok(new { total = dw.Count, items });
|
|
// return Ok(new(total = dw.Count,menu2));
|
|
}
|
|
else
|
|
{
|
|
return BadRequest("current");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 修改模式
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="checkStation"></param>
|
|
/// <param name="stationModel"></param>
|
|
/// <param name="wareHouse"></param>
|
|
/// <param name="stationType"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("{id}")]
|
|
public IActionResult Modify(
|
|
[FromRoute] string id,
|
|
[FromMember] string checkStation,
|
|
[FromMember] string stationModel,
|
|
[FromMember] string wareHouse,
|
|
[FromMember] string stationType)
|
|
{
|
|
int a;
|
|
string error;
|
|
#region 需要加上重复Code的校验
|
|
#endregion
|
|
var set = "";
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
set = $"{set}, F_Station_Code = '{id}'";
|
|
}
|
|
if (!string.IsNullOrEmpty(checkStation))
|
|
{
|
|
set = $"{set}, F_CheckStation = '{checkStation}'";
|
|
}
|
|
if (!string.IsNullOrEmpty(stationModel))
|
|
{
|
|
set = $"{set}, F_Station_Model = {stationModel}";
|
|
}
|
|
if (!string.IsNullOrEmpty(wareHouse))
|
|
{
|
|
set = $"{set}, F_WareHouse = {wareHouse}";
|
|
}
|
|
if (!string.IsNullOrEmpty(stationType))
|
|
{
|
|
string stationTypeDes = "1";
|
|
if (stationType == "出库") { stationTypeDes = "2"; }
|
|
set = $"{set}, F_Station_Type = {stationTypeDes}";
|
|
}
|
|
|
|
#region 出入库反向任务校验
|
|
bool Have = false;
|
|
int writevalue = 0;
|
|
if (stationType == "入库")
|
|
{
|
|
Have = ccf.HaveOutTaskToEnd(Convert.ToInt32(id));
|
|
writevalue = 1;
|
|
}
|
|
else
|
|
{
|
|
Have = ccf.HaveInTaskFromStart(Convert.ToInt32(id));
|
|
writevalue = 2;
|
|
}
|
|
if (Have)
|
|
{
|
|
return StatusCode(422);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 给电气设备写出入库模式,暂定id设备的DB2,预留位7---DB2被电气刷新---- DB1第9字节
|
|
StringBuilder[] wv = { new StringBuilder("2") };
|
|
StringBuilder[] witemnames = { new StringBuilder("") };
|
|
|
|
Model.MDevice md = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(id));
|
|
witemnames[0].Clear();
|
|
witemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(md.Dbw2Address + 9)).Append(",b");
|
|
wv[0].Clear();
|
|
wv[0].Append(writevalue.ToString());
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(Convert.ToInt32(id));
|
|
sdo.WriteDBData(witemnames, wv, md.S7Connection);
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("StationStatusController", "设定站台模式", id.ToString(), "模式:" + writevalue.ToString());
|
|
|
|
#endregion
|
|
|
|
|
|
var value = set.Trim(',');
|
|
int count = CStaticClass.dbo.ExecuteSql($"UPDATE T_Base_Station_Model SET " + value + $" where F_Station_Code= '{id}'");
|
|
|
|
if (count > 0)
|
|
{
|
|
#region 加上同时更新缓存的代码
|
|
#endregion
|
|
return Ok();
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(422);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取站台类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("statuskind")]
|
|
public IActionResult Get()
|
|
{
|
|
//var sql = $"SELECT F_TaskKindIndex,F_TaskKindName from T_Base_manage_task_kind order by F_TaskKindIndex";
|
|
|
|
//dv = CStaticClass.dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
var items = new dynamic[2];
|
|
items[0] = new { id = 1, name = "入库", };
|
|
items[1] = new { id = 2, name = "出库", };
|
|
return Ok(new { total = 2, items });
|
|
}
|
|
}
|
|
}
|