using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using WCS.Entity; using WMS.BZModels.Dto.PT.WareCellDtos; using WMS.BZServices.PT; using WMS.Info; namespace WMS.BZWeb.Areas.PTManager.Controllers { [Area("PTManager")] public class QueryCellController : MvcControllerBase { private readonly WareCellService _wareCellService ; public QueryCellController(WareCellService wareCellService) { _wareCellService = wareCellService; } #region 视图功能 public IActionResult Index() { return View(); } public IActionResult Form() { return View(); } #endregion #region 获取数据 [HttpPost] public ActionResult GetMaxLine(string houseNo) { var data = _wareCellService.GetMaxLine("pthouse"); return Success("", data); } [HttpPost] public ActionResult GetLocViewList(string query) { var querydto = JsonConvert.DeserializeObject(query); if (querydto == null || string.IsNullOrEmpty(querydto.SCRel)) { return Success("", new StockLocationViewDto()); } var list = _wareCellService.GetLocList(querydto); return Success("", list); } [HttpGet] public ActionResult GetSelectSRMNameList() { var list = _wareCellService.GetSelectSRMNameList(); return Success(list); } [HttpPost] public ActionResult GetLocList(string houserNo, int line) { _wareCellService.GetLocList(new WarecellQuery { SCRel = "SRM01" }); var data = _wareCellService.GetLocList(houserNo, line); var json = "["; int y = 0; int x = 0; foreach (WarecellDto entity in data) { if (entity.Layer > y) { y = entity.Layer; } if (entity.Col > x) { x = entity.Col; } var color = ""; if (entity.IsStop == 1) { color = "#CCC"; } else { if (entity.StateNum == 1) { color = "#4EEE94"; } else if (entity.StateNum == 2) { color = "#191970"; } else if (entity.StateNum == 3) { color = "#CD69C9"; } else if (entity.StateNum == 4) { color = "#CD0000"; } } double y1 = 0; double y2 = 0; if (entity.Depth == 2) { y1 = (entity.Layer + 0.6); y2 = (entity.Layer + 0.9); } else { y1 = entity.Layer + 0.1; y2 = entity.Layer + 0.4; } int result = 0; if (entity.IsStop != 1) { result = entity.StateNum.HasValue? entity.StateNum.Value:0; } json += "{"; //json += @"name:'" + entity.F_WAREHOUSENO + "',fNo:'" + entity.F_NO + "',value:[" + y1 + "," + y2 + "," // + (entity.F_COL + 0.1) + "," + (entity.F_COL + 0.9) + "],itemStyle:{normal:{color:'" + color + "'}}},"; json += @"name:'" + entity.WarehouseCode + "',fNo:'" + entity.Id + "',F_ISSTOP:" + entity.IsStop + ",F_STATENUM:" + entity.StateNum + ",F_COL:" + entity.Col + ",F_LAYER:" + entity.Layer + ",F_DEPTH:" + entity.Depth + ",STATE:'" + StateText(result) + "'" + ",F_CNTRGRPNO:'" + "'" + ",value:[" + y1 + "," + y2 + "," + (entity.Col + 0.1) + "," + (entity.Col + 0.9) + "],itemStyle:{normal:{color:'" + color + "'}}},"; } json = json.TrimEnd(',') + "]"; var retData = new { json, x, y }; return Success("", retData); } private string StateText(int state) { var stateText = ""; switch (state) { case 0: stateText = "停用"; break; case 1: stateText = "空货位"; break; case 2: stateText = "已存储"; break; case 3: stateText = "入锁"; break; case 4: stateText = "出锁"; break; } return stateText; } #endregion } }