ZhongTianHjService.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using AutoMapper;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Text;
  8. using Wms.Screen.DataService.Interface;
  9. using Wms.Screen.Dto;
  10. using Wms.Screen.Dto.ZhongTian;
  11. using Wms.Screen.Dto.ZhongTian.Request;
  12. using Wms.Screen.Dto.ZhongTian.Response;
  13. using Wms.Screen.Service.IService;
  14. using Wms.Screen.SqlSugar.ZhongTian;
  15. using Wms.Screen.Util.Extensions;
  16. namespace Wms.Screen.Service.Service
  17. {
  18. public class ZhongTianHjService : IZhongTianHjService
  19. {
  20. private readonly IZhongTianHjDataService _zhongTianHjDataService;
  21. private readonly IMapper _mapper;
  22. public ZhongTianHjService(IMapper mapper, IZhongTianHjDataService zhongTianHjDataService)
  23. {
  24. _mapper = mapper;
  25. _zhongTianHjDataService = zhongTianHjDataService;
  26. }
  27. public List<EquipDto> GetHjEquips(GetEquipsRequest reqEntity)
  28. {
  29. var real = new List<EquipDto>();
  30. var list = _zhongTianHjDataService.GetHjEquips(reqEntity);
  31. var tun1 = list.Where(p => p.Tunnel == "1").Count();
  32. var tun2 = list.Where(p => p.Tunnel == "2").Count();
  33. var tun3 = list.Where(p => p.Tunnel == "3").Count();
  34. var srm = RedisHelper.Get("Alloy:SrmStatus");
  35. var msgdto = JsonConvert.DeserializeObject<List<SRMEquipDto>>(srm);
  36. foreach (var item in msgdto)
  37. {
  38. EquipDto equip = new EquipDto();
  39. if (item.Item1 == "SRM3")
  40. {
  41. if (item.Item2 == "Automatic")
  42. {
  43. equip.EquipState = "1";
  44. equip.Code = "SRM3";
  45. equip.ResidueTask = tun3;
  46. }
  47. else if (item.Item2 == "Manual")
  48. {
  49. equip.EquipState = "2";
  50. equip.Code = "SRM3";
  51. equip.ResidueTask = tun3;
  52. }
  53. else
  54. {
  55. equip.EquipState = "3";
  56. equip.Code = "SRM3";
  57. equip.ResidueTask = tun3;
  58. }
  59. }
  60. else if (item.Item1 == "SRM2")
  61. {
  62. if (item.Item2 == "Automatic")
  63. {
  64. equip.EquipState = "1";
  65. equip.Code = "SRM2";
  66. equip.ResidueTask = tun2;
  67. }
  68. else if (item.Item2 == "Manual")
  69. {
  70. equip.EquipState = "2";
  71. equip.Code = "SRM2";
  72. equip.ResidueTask = tun2;
  73. }
  74. else
  75. {
  76. equip.EquipState = "3";
  77. equip.Code = "SRM2";
  78. equip.ResidueTask = tun2;
  79. }
  80. }
  81. else if (item.Item1 == "SRM1")
  82. {
  83. if (item.Item2 == "Automatic")
  84. {
  85. equip.EquipState = "1";
  86. equip.Code = "SRM1";
  87. equip.ResidueTask = tun1;
  88. }
  89. else if (item.Item2 == "Manual")
  90. {
  91. equip.EquipState = "2";
  92. equip.Code = "SRM1";
  93. equip.ResidueTask = tun1;
  94. }
  95. else
  96. {
  97. equip.EquipState = "3";
  98. equip.Code = "SRM1";
  99. equip.ResidueTask = tun1;
  100. }
  101. }
  102. else
  103. {
  104. continue;
  105. }
  106. real.Add(equip);
  107. }
  108. return real;
  109. }
  110. /// <summary>
  111. /// 获取合金任务货位分布
  112. /// </summary>
  113. /// <param name="ReqEntity"></param>
  114. /// <returns></returns>
  115. public List<ItemVal> GetLocaitonList()
  116. {
  117. List<ItemVal> res = new List<ItemVal>();
  118. var list = _zhongTianHjDataService.GetLocationList();
  119. res.Add(new ItemVal() { Name = "空", Value = list.Where(p => p.StateNum == 1).Any() ? list.Where(p => p.StateNum == 1).Count() : 0 });
  120. res.Add(new ItemVal() { Name = "满", Value = list.Where(p => p.StateNum == 2).Any() ? list.Where(p => p.StateNum == 2).Count() : 0 });
  121. res.Add(new ItemVal() { Name = "锁定", Value = list.Where(p => p.StateNum == 3 || p.StateNum == 4).Any() ? list.Where(p => p.StateNum == 3 || p.StateNum == 4).Count() : 0 });
  122. res.Add(new ItemVal() { Name = "禁用", Value = list.Where(p => p.IsStop == 1).Any() ? list.Where(p => p.IsStop == 1).Count() : 0 });
  123. return res;
  124. }
  125. /// <summary>
  126. /// 获取合金空满轮分布
  127. /// </summary>
  128. /// <param name="ReqEntity"></param>
  129. /// <returns></returns>
  130. public List<ItemVal> GetEmptyFullDist()
  131. {
  132. List<ItemVal> res = new List<ItemVal>();
  133. var list = _zhongTianHjDataService.GetBillInvnowList();
  134. res.Add(new ItemVal() { Name = "空轮", Value = list.Where(p => p.ContGrpType == 2).Any() ? list.Where(p => p.ContGrpType == 2).Count() : 0 });
  135. res.Add(new ItemVal() { Name = "满轮", Value = list.Where(p => p.ContGrpType == 1).Any() ? list.Where(p => p.ContGrpType == 1).Count() : 0 });
  136. return res;
  137. }
  138. public List<ItemVal> GetTunelCountList()
  139. {
  140. List<ItemVal> res = new List<ItemVal>();
  141. var list = _zhongTianHjDataService.GetTunelCountList();
  142. foreach (var item in list)
  143. {
  144. if (item.Tunnel.HasValue)
  145. {
  146. res.Add(new ItemVal()
  147. {
  148. Name = item.Tunnel + "巷道" + (item.ContGrpType == 2 ? "空轮" : "满轮"),
  149. Value = item.Qty
  150. });
  151. }
  152. }
  153. return res;
  154. }
  155. /// <summary>
  156. /// 获取历史任务信息
  157. /// </summary>
  158. /// <param name="ReqEntity"></param>
  159. /// <returns></returns>
  160. public GeHistoryTaskInfoRes GeHistoryTaskInfo(GeHistoryTaskInfoRequest ReqEntity)
  161. {
  162. GeHistoryTaskInfoRes res = new GeHistoryTaskInfoRes();
  163. var list = _zhongTianHjDataService.GeHistoryTaskInfo(ReqEntity);
  164. res.DateList = new List<string>() { DateTime.Now.AddDays(-6).ToShortDateString(),
  165. DateTime.Now.AddDays(-5).ToShortDateString(),DateTime.Now.AddDays(-4).ToShortDateString(),DateTime.Now.AddDays(-3).ToShortDateString(),
  166. DateTime.Now.AddDays(-2).ToShortDateString(),DateTime.Now.AddDays(-1).ToShortDateString(),DateTime.Now.ToShortDateString()};
  167. res.StockInList = new List<int>() {
  168. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-6).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-6).Date).Count():0 ,
  169. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-5).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-5).Date).Count():0 ,
  170. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-4).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-4).Date).Count():0 ,
  171. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-3).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-3).Date).Count():0 ,
  172. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-2).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-2).Date).Count():0 ,
  173. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-1).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-1).Date).Count():0 ,
  174. list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.Date).Count():0 ,
  175. };
  176. res.StockOutList = new List<int>() {
  177. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-6).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-6).Date).Count():0 ,
  178. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-5).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-5).Date).Count():0 ,
  179. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-4).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-4).Date).Count():0 ,
  180. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-3).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-3).Date).Count():0 ,
  181. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-2).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-2).Date).Count():0 ,
  182. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-1).Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.AddDays(-1).Date).Count():0 ,
  183. list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.Date).Any() ? list.Where(p=>p.BusType == "二楼湿拉自动叫料出库" && p.AddTime.Date == DateTime.Now.Date).Count():0 ,
  184. };
  185. return res;
  186. }
  187. /// <summary>
  188. /// 获取合金任务信息
  189. /// </summary>
  190. /// <param name="ReqEntity"></param>
  191. /// <returns></returns>
  192. public List<TaskInfoDto> GetHjTaskInfo(GetWcsTaskInfoRequest ReqEntity)
  193. {
  194. List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
  195. taskInfoDtos = _zhongTianHjDataService.GetHjRunWcsTaskInfo(ReqEntity);
  196. return taskInfoDtos;
  197. }
  198. /// <summary>
  199. /// 获取合金重量轮分布
  200. /// </summary>
  201. /// <param name="ReqEntity"></param>
  202. /// <returns></returns>
  203. public GetFullWeightDistRes GetFullWeightDist()
  204. {
  205. GetFullWeightDistRes res = new GetFullWeightDistRes() { xData = new List<string>(), yData = new List<decimal>() };
  206. List<ItemVal> listtemp = new List<ItemVal>();
  207. var list = _zhongTianHjDataService.GetBillInvnowList().Where(p => p.ContGrpType == 1 && p.InvStateCode == "InvEcecState_In");
  208. foreach (var item in list.GroupBy(p => p.MatCode))
  209. {
  210. res.xData.Add(item.Key);
  211. res.yData.Add(item.Sum(q => q.NetWQty));
  212. }
  213. return res;
  214. }
  215. public List<ZTBillDto> GetHjBillList(GetWorkPlanBillListRequest reqEntity)
  216. {
  217. var list = _zhongTianHjDataService.GetHjBillList(reqEntity);
  218. if (list.Any())
  219. {
  220. foreach (var item in list)
  221. {
  222. if (item.TypeCode == DocType.DocType_HJ_CopperProductStockIn.GetHashCode().ToString())
  223. {
  224. item.TypeCode = DocType.DocType_HJ_CopperProductStockIn.GetDescription();
  225. }
  226. else if (item.TypeCode == DocType.DocType_HJ_WetLinePickMaterApply.GetHashCode().ToString())
  227. {
  228. item.TypeCode = DocType.DocType_HJ_WetLinePickMaterApply.GetDescription();
  229. }
  230. else if (item.TypeCode == DocType.DocType_HJ_WetLineBack.GetHashCode().ToString())
  231. {
  232. item.TypeCode = DocType.DocType_HJ_WetLineBack.GetDescription();
  233. }
  234. else if (item.TypeCode == DocType.DocType_HJ_WetLineLeft.GetHashCode().ToString())
  235. {
  236. item.TypeCode = DocType.DocType_HJ_WetLineLeft.GetDescription();
  237. }
  238. }
  239. }
  240. return list;
  241. }
  242. public Result<int> GetEmtpyLocationCountByTunnel(List<string> tunnels, int size)
  243. {
  244. var result = new Result<int>() { ReturnValue = 0 };
  245. //var model = _zhongTianHjDataService.GetEmtpyLocationCountByTunnel(tunnels, size);
  246. //result.ReturnValue = model;
  247. return result;
  248. }
  249. public Result<int> GetRuningInTaskCountByTunnel(int tunnel, string warehousecode, int size)
  250. {
  251. var result = new Result<int>() { ReturnValue = 0 };
  252. var model = _zhongTianHjDataService.GetRuningInTaskCountByTunnel(tunnel, warehousecode, size);
  253. if (model != null)
  254. {
  255. result.ReturnValue = model;
  256. }
  257. return result;
  258. }
  259. public PageResult<ZtLocationUsageReportViewDto> GetHjLocationUsageViewList()
  260. {
  261. var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
  262. //查询巷道的禁用/启用信息
  263. //var configTunnelList = _zhongTianHjDataService.GetTunnelConfigList(new DetailCodeRequest() { Code = "" })?.ReturnValue;
  264. var list = _zhongTianHjDataService.GetHjLocationUsageReportList();
  265. //if (configTunnelList != null && configTunnelList.Any())
  266. //{
  267. // //更新巷道状态
  268. // list.ForEach(s =>
  269. // {
  270. // var conf = configTunnelList.Where(m => m.WarehouseName == s.WarehouseName && m.Tunnel == s.Tunnel.Substring(0, 1)).FirstOrDefault();
  271. // if (conf != null)
  272. // {
  273. // s.InStates = conf.InStates;
  274. // s.OutStates = conf.OutStates;
  275. // }
  276. // });
  277. //}
  278. result.ReturnValue = list.ToList();
  279. result.ItemGroupSum = new List<ItemGroup>() {
  280. new ItemGroup(){ UnitName="总货位",qty=list.Sum(s=>s.AllLocationTotal)},
  281. new ItemGroup(){ UnitName="有效货位",qty=list.Sum(s=>s.CanUseLocation)},
  282. new ItemGroup(){ UnitName="空余货位",qty=list.Sum(s=>s.SpareLocation)},
  283. new ItemGroup(){ UnitName="锁定货位",qty=list.Sum(s=>s.LockLocation)},
  284. new ItemGroup(){ UnitName="停用货位",qty=list.Sum(s=>s.StopLocation)},
  285. new ItemGroup(){ UnitName="有料货位",qty=list.Sum(s=>s.MaterilLocation)},
  286. new ItemGroup(){ UnitName="有容器货位",qty=list.Sum(s=>s.ContainLocation)}
  287. };
  288. return result;
  289. }
  290. }
  291. }