ZhongTianCpService.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using AutoMapper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Wms.Screen.DataService.Interface;
  6. using Wms.Screen.Dto.ZhongTian.Request;
  7. using Wms.Screen.Dto.ZhongTian.Response;
  8. using Wms.Screen.Dto.ZhongTian;
  9. using Wms.Screen.Service.IService;
  10. using Wms.Screen.DataService.Impl;
  11. using Wms.Screen.Dto;
  12. using System.Linq;
  13. using Newtonsoft.Json;
  14. using CSRedis;
  15. namespace Wms.Screen.Service.Service
  16. {
  17. /// <summary>
  18. /// 成品
  19. /// </summary>
  20. public class ZhongTianCpService : IZhongTianCpService
  21. {
  22. private IZhongTianCpDataService _zhongTianCpDataService;
  23. private IMapper _mapper;
  24. public ZhongTianCpService(IZhongTianCpDataService zhongTianCpDataService, IMapper mapper)
  25. {
  26. _zhongTianCpDataService = zhongTianCpDataService;
  27. _mapper = mapper;
  28. }
  29. public List<EquipDto> GetCpEquips(GetEquipsRequest reqEntity, CSRedisClient CSRedisClient)
  30. {
  31. var real = new List<EquipDto>();
  32. var list = _zhongTianCpDataService.GetCpEquips(reqEntity);
  33. var srm = CSRedisClient.Get("Cp:SrmStatus");
  34. if (srm == null) return real;
  35. var msgdto = JsonConvert.DeserializeObject<List<SRMEquipDto>>(srm);
  36. foreach (var item in msgdto)
  37. {
  38. EquipDto equip = new EquipDto();
  39. switch (item.Item1)
  40. {
  41. case "SRM1":
  42. if (item.Item2 == "Automatic")
  43. {
  44. equip.EquipState = "1";
  45. equip.Code = "SRM1";
  46. equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
  47. }
  48. else if (item.Item2 == "Manual")
  49. {
  50. equip.EquipState = "2";
  51. equip.Code = "SRM1";
  52. equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
  53. }
  54. else
  55. {
  56. equip.EquipState = "3";
  57. equip.Code = "SRM1";
  58. equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
  59. }
  60. real.Add(equip);
  61. break;
  62. case "SRM2":
  63. if (item.Item2 == "Automatic")
  64. {
  65. equip.EquipState = "1";
  66. equip.Code = "SRM2";
  67. equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
  68. }
  69. else if (item.Item2 == "Manual")
  70. {
  71. equip.EquipState = "2";
  72. equip.Code = "SRM2";
  73. equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
  74. }
  75. else
  76. {
  77. equip.EquipState = "3";
  78. equip.Code = "SRM2";
  79. equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
  80. }
  81. real.Add(equip);
  82. break;
  83. case "SRM3":
  84. if (item.Item2 == "Automatic")
  85. {
  86. equip.EquipState = "1";
  87. equip.Code = "SRM3";
  88. equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
  89. }
  90. else if (item.Item2 == "Manual")
  91. {
  92. equip.EquipState = "2";
  93. equip.Code = "SRM3";
  94. equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
  95. }
  96. else
  97. {
  98. equip.EquipState = "3";
  99. equip.Code = "SRM3";
  100. equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
  101. }
  102. real.Add(equip);
  103. break;
  104. case "SRM4":
  105. if (item.Item2 == "Automatic")
  106. {
  107. equip.EquipState = "1";
  108. equip.Code = "SRM4";
  109. equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
  110. }
  111. else if (item.Item2 == "Manual")
  112. {
  113. equip.EquipState = "2";
  114. equip.Code = "SRM4";
  115. equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
  116. }
  117. else
  118. {
  119. equip.EquipState = "3";
  120. equip.Code = "SRM4";
  121. equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
  122. }
  123. real.Add(equip);
  124. break;
  125. case "SRM5":
  126. if (item.Item2 == "Automatic")
  127. {
  128. equip.EquipState = "1";
  129. equip.Code = "SRM5";
  130. equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
  131. }
  132. else if (item.Item2 == "Manual")
  133. {
  134. equip.EquipState = "2";
  135. equip.Code = "SRM5";
  136. equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
  137. }
  138. else
  139. {
  140. equip.EquipState = "3";
  141. equip.Code = "SRM5";
  142. equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
  143. }
  144. real.Add(equip);
  145. break;
  146. default:
  147. break;
  148. }
  149. }
  150. return real.OrderBy(p => p.Code).ToList();
  151. }
  152. /// <summary>
  153. /// 获取成品任务信息
  154. /// </summary>
  155. /// <param name="ReqEntity"></param>
  156. /// <returns></returns>
  157. public List<TaskInfoDto> GetCpTaskInfo(GetWcsTaskInfoRequest ReqEntity)
  158. {
  159. List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
  160. taskInfoDtos = _zhongTianCpDataService.GetCpRunWcsTaskInfo(ReqEntity);
  161. return taskInfoDtos;
  162. }
  163. public List<ZTBillDto> GetCpBillList(GetWorkPlanBillListRequest reqEntity)
  164. {
  165. var list = _zhongTianCpDataService.GetCpBillList(reqEntity);
  166. return list;
  167. }
  168. public PageResult<ZtLocationUsageReportViewDto> GetCpLocationUsageViewList()
  169. {
  170. var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
  171. var list = _zhongTianCpDataService.GetCpLocationUsageReportList();
  172. result.ReturnValue = list.ToList();
  173. result.ItemGroupSum = new List<ItemGroup>() {
  174. new ItemGroup(){ UnitName="总货位",qty=list.Sum(s=>s.AllLocationTotal)},
  175. new ItemGroup(){ UnitName="有效货位",qty=list.Sum(s=>s.CanUseLocation)},
  176. new ItemGroup(){ UnitName="空余货位",qty=list.Sum(s=>s.SpareLocation)},
  177. new ItemGroup(){ UnitName="锁定货位",qty=list.Sum(s=>s.LockLocation)},
  178. new ItemGroup(){ UnitName="停用货位",qty=list.Sum(s=>s.StopLocation)},
  179. new ItemGroup(){ UnitName="有料货位",qty=list.Sum(s=>s.MaterilLocation)},
  180. new ItemGroup(){ UnitName="有容器货位",qty=list.Sum(s=>s.ContainLocation)}
  181. };
  182. return result;
  183. }
  184. public List<ItemVal> GetTrayProductList()
  185. {
  186. List<ItemVal> res = new List<ItemVal>();
  187. var list = _zhongTianCpDataService.GetTrayProductList();
  188. res.Add(new ItemVal() { Name = "空托盘", Value = list.Where(p => p.ContGrpType == 2).Any() ? list.Where(p => p.ContGrpType == 2).Count() : 0 });
  189. res.Add(new ItemVal() { Name = "中间隔板", Value = list.Where(p => p.ContGrpType == 3).Any() ? list.Where(p => p.ContGrpType == 3).Count() : 0 });
  190. res.Add(new ItemVal() { Name = "成品", Value = list.Where(p => p.ContGrpType == 1).Any() ? list.Where(p => p.ContGrpType == 1).Count() : 0 });
  191. var locationslists = _zhongTianCpDataService.GetLocationList();
  192. res.Add(new ItemVal() { Name = "空位", Value = locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Any() ? locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Count() : 0 });
  193. return res;
  194. }
  195. public List<WarningQtyModel> GetWarningQtyList(MySettings mySettings)
  196. {
  197. List<WarningQtyModel> res = new List<WarningQtyModel>();
  198. var list = _zhongTianCpDataService.GetTrayProductList();
  199. var qty = list.Where(p => p.ContGrpType == 2).Any() ? list.Where(p => p.ContGrpType == 2).Count() : 0;
  200. res.Add(new WarningQtyModel()
  201. {
  202. Name = "空托盘",
  203. Qty = qty,
  204. WarnQty = mySettings.MaternalCareWarning
  205. });
  206. qty = list.Where(p => p.ContGrpType == 3).Any() ? list.Where(p => p.ContGrpType == 3).Count() : 0;
  207. res.Add(new WarningQtyModel() { Name = "中间隔板", Qty = qty,WarnQty=mySettings.PartitionWarning });
  208. var locationslists = _zhongTianCpDataService.GetLocationList();
  209. qty = locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Any() ? locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Count() : 0;
  210. res.Add(new WarningQtyModel() { Name = "空位", Qty =qty,WarnQty=mySettings.VacancyWarning });
  211. return res;
  212. }
  213. /// <summary>
  214. /// 获取产品信息
  215. /// </summary>
  216. /// <returns></returns>
  217. public DeliveryDetails GetProductInfoList()
  218. {
  219. var value=RedisHelper.Get("Cp:ProductTaskInfos");
  220. var productInfoListRequset = JsonConvert.DeserializeObject<List<ProductInfoListRequset>>(value);
  221. var dataInfo=_zhongTianCpDataService.GetProductInfoList(productInfoListRequset);
  222. return dataInfo;
  223. }
  224. }
  225. }