|
using HH.AutoBom.Core;
|
using HH.WMS.Common;
|
using HH.WMS.Entitys;
|
using HH.WMS.Entitys.Sys;
|
using HH.WMS.WebUI.Controllers;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Linq;
|
using System.Net.Sockets;
|
using System.Web;
|
using System.Web.Configuration;
|
using System.Web.Mvc;
|
|
namespace HH.WMS.WebUI.Areas.Sys.Controllers
|
{
|
[AllowAnonymous]
|
[MvcMenuFilter(false)]
|
public class SysSetController : BaseController
|
{
|
public ActionResult Index()
|
{
|
return View();
|
}
|
public ActionResult SysConfig()
|
{
|
ViewData["CN_S_WMS_API"] = Constants.SysConfig.WMS_API;
|
return View();
|
}
|
|
public string GetWebConfig()
|
{
|
return HttpWMS_Get("api/Strategy/GetWebConfig");
|
}
|
|
public string TestDb(string dbUrl, string dbType)
|
{
|
dbUrl = HttpUtility.UrlEncode(dbUrl, System.Text.Encoding.UTF8).Replace("+", "%20");
|
return HttpWMS_Get("api/Strategy/TestDb?dbUrl=" + dbUrl + "&dbType=" + dbType);
|
}
|
public string TestWmsApi(string ipPort)
|
{
|
TcpClient client = new TcpClient();
|
try
|
{
|
var ar = client.BeginConnect(ipPort.Split(':')[0], Convert.ToInt32(ipPort.Split(':')[1]), null, null);
|
ar.AsyncWaitHandle.WaitOne(2000);
|
if (client.Connected)
|
{
|
|
Constants.SysConfig.WMS_API=ipPort;
|
//SetAppSettingsSection("wms_ipAddress", ipPort);
|
|
return JsonConvert.SerializeObject(OperateResult.Succeed());
|
}
|
else
|
return JsonConvert.SerializeObject(OperateResult.Error());
|
}
|
catch (Exception e)
|
{
|
return JsonConvert.SerializeObject(OperateResult.Error());
|
}
|
finally
|
{
|
client.Close();
|
}
|
}
|
|
public string TestIpPort(string ipPort)
|
{
|
return HttpWMS_Get("api/Strategy/TestIpPort?ipPort=" + ipPort);
|
}
|
public string SaveWebConfig(SysConfigParamEntity model)
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
model.TokenId = loginer.Extend1;
|
SetAppSettingsSection("RedisPath", model.REDIS);
|
SetAppSettingsSection("DefaultDb", model.REDIS_DB);
|
|
string result = HttpWMS_Post("Api/Strategy/SaveWebConfig", JsonConvert.SerializeObject(model));
|
|
Constants.SysConfig = model;
|
|
return result;
|
}
|
|
Configuration config;
|
|
public void SetAppSettingsSection(string key, string value)
|
{
|
config = WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);
|
AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");
|
if (appSettings.Settings[key] != null)
|
{
|
if (appSettings.Settings[key].Value != value)
|
{
|
appSettings.Settings[key].Value = value;
|
config.Save();
|
}
|
}
|
else
|
{
|
appSettings.Settings.Add(key, value);
|
config.Save();
|
}
|
}
|
|
#region 获取策略项目
|
/// <summary>
|
/// 获取策略项目
|
/// </summary>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] created by 2018/12/04</History>
|
public string GetSetOption()
|
{
|
return HttpWMS_Get("api/Strategy/GetSysSetList");
|
}
|
#endregion
|
#region 获取策略值
|
/// <summary>
|
/// 获取策略值
|
/// </summary>
|
/// <param name="stockCode">仓库号</param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] created by 2018/12/04</History>
|
public string GetOptionValue(string stockCode)
|
{
|
return HttpWMS_Get("api/Strategy/GetOptionValue?stockCode=" + stockCode);
|
}
|
#endregion
|
|
#region 策略保存
|
/// <summary>
|
/// 策略保存
|
/// </summary>
|
/// <param name="stockCode">仓库号</param>
|
/// <param name="ChangedItems">变更项</param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] created by 2018/12/04</History>
|
public string Save(string stockCode, string ChangedItems)
|
{
|
return HttpWMS_Get("api/Strategy/Save?stockCode=" + stockCode + "&ChangedItems=" + ChangedItems);
|
}
|
#endregion
|
|
#region 打单配置
|
|
public ActionResult WaveSet()
|
{
|
return View();
|
}
|
|
public string GetAutoAreas()
|
{
|
return HttpWMS_Get("api/WaveSet/GetAutoAreas");
|
}
|
|
public string GetWaveStrategy(string stockCode)
|
{
|
return HttpWMS_Get("api/WaveSet/GetWaveStrategy?stockCode=" + stockCode);
|
}
|
|
public string UpdateWaveStrategy(string stockCode, string startTime, string endTime, string severalMaxCreateWave, string lessMinute)
|
{
|
List<TN_WM_B_STRATEGY_VALUEEntity> strategyValues = new List<TN_WM_B_STRATEGY_VALUEEntity>();
|
strategyValues.Add(new TN_WM_B_STRATEGY_VALUEEntity
|
{
|
CN_S_STOCK_CODE = stockCode,
|
CN_S_CODE = Constants.Strategy_StartTime,
|
CN_S_VALUE = startTime
|
});
|
strategyValues.Add(new TN_WM_B_STRATEGY_VALUEEntity
|
{
|
CN_S_STOCK_CODE = stockCode,
|
CN_S_CODE = Constants.Strategy_EndTime,
|
CN_S_VALUE = endTime
|
});
|
strategyValues.Add(new TN_WM_B_STRATEGY_VALUEEntity
|
{
|
CN_S_STOCK_CODE = stockCode,
|
CN_S_CODE = Constants.Strategy_SeveralMaxCreateWave,
|
CN_S_VALUE = severalMaxCreateWave
|
});
|
strategyValues.Add(new TN_WM_B_STRATEGY_VALUEEntity
|
{
|
CN_S_STOCK_CODE = stockCode,
|
CN_S_CODE = Constants.Strategy_LessMinute,
|
CN_S_VALUE = lessMinute
|
});
|
var postEntity = new
|
{
|
TokenId = ViewConstants.TokenId,
|
PostData = strategyValues
|
};
|
return HttpWMS_Post("api/WaveSet/UpdateWaveStrategy", JsonConvert.SerializeObject(postEntity));
|
}
|
|
public string SetServiceMode(string areaCode, string serviceMode)
|
{
|
return HttpWMS_Get("api/WaveSet/SetServiceMode?areaCode=" + areaCode + "&serviceMode=" + serviceMode);
|
}
|
#endregion
|
}
|
}
|