| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using AutoMapper;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Wms.Screen.DataService.Interface;
- using Wms.Screen.Dto.ZhongTian.Request;
- using Wms.Screen.Dto.ZhongTian.Response;
- using Wms.Screen.Dto.ZhongTian;
- using Wms.Screen.Service.IService;
- using Wms.Screen.DataService.Impl;
- using Wms.Screen.Dto;
- using System.Linq;
- using Newtonsoft.Json;
- using CSRedis;
- namespace Wms.Screen.Service.Service
- {
- /// <summary>
- /// 成品
- /// </summary>
- public class ZhongTianCpService : IZhongTianCpService
- {
- private IZhongTianCpDataService _zhongTianCpDataService;
- private IMapper _mapper;
- public ZhongTianCpService(IZhongTianCpDataService zhongTianCpDataService, IMapper mapper)
- {
- _zhongTianCpDataService = zhongTianCpDataService;
- _mapper = mapper;
- }
- public List<EquipDto> GetCpEquips(GetEquipsRequest reqEntity, CSRedisClient CSRedisClient)
- {
- var real = new List<EquipDto>();
- var list = _zhongTianCpDataService.GetCpEquips(reqEntity);
- var srm = CSRedisClient.Get("Cp:SrmStatus");
- if (srm == null) return real;
- var msgdto = JsonConvert.DeserializeObject<List<SRMEquipDto>>(srm);
- foreach (var item in msgdto)
- {
- EquipDto equip = new EquipDto();
- switch (item.Item1)
- {
- case "SRM1":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1").Count();
- }
- real.Add(equip);
- break;
- case "SRM2":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "2").Count();
- }
- real.Add(equip);
- break;
- case "SRM3":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3").Count();
- }
- real.Add(equip);
- break;
- case "SRM4":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "4").Count();
- }
- real.Add(equip);
- break;
- case "SRM5":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM5";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM5";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM5";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5").Count();
- }
- real.Add(equip);
- break;
- default:
- break;
- }
- }
- return real.OrderBy(p => p.Code).ToList();
- }
- /// <summary>
- /// 获取成品任务信息
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public List<TaskInfoDto> GetCpTaskInfo(GetWcsTaskInfoRequest ReqEntity)
- {
- List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
- taskInfoDtos = _zhongTianCpDataService.GetCpRunWcsTaskInfo(ReqEntity);
- return taskInfoDtos;
- }
- public List<ZTBillDto> GetCpBillList(GetWorkPlanBillListRequest reqEntity)
- {
- var list = _zhongTianCpDataService.GetCpBillList(reqEntity);
- return list;
- }
- public PageResult<ZtLocationUsageReportViewDto> GetCpLocationUsageViewList()
- {
- var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
- var list = _zhongTianCpDataService.GetCpLocationUsageReportList();
- result.ReturnValue = list.ToList();
- result.ItemGroupSum = new List<ItemGroup>() {
- new ItemGroup(){ UnitName="总货位",qty=list.Sum(s=>s.AllLocationTotal)},
- new ItemGroup(){ UnitName="有效货位",qty=list.Sum(s=>s.CanUseLocation)},
- new ItemGroup(){ UnitName="空余货位",qty=list.Sum(s=>s.SpareLocation)},
- new ItemGroup(){ UnitName="锁定货位",qty=list.Sum(s=>s.LockLocation)},
- new ItemGroup(){ UnitName="停用货位",qty=list.Sum(s=>s.StopLocation)},
- new ItemGroup(){ UnitName="有料货位",qty=list.Sum(s=>s.MaterilLocation)},
- new ItemGroup(){ UnitName="有容器货位",qty=list.Sum(s=>s.ContainLocation)}
- };
- return result;
- }
- public List<ItemVal> GetTrayProductList()
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianCpDataService.GetTrayProductList();
- res.Add(new ItemVal() { Name = "空托盘", Value = list.Where(p => p.ContGrpType == 2).Any() ? list.Where(p => p.ContGrpType == 2).Count() : 0 });
- res.Add(new ItemVal() { Name = "中间隔板", Value = list.Where(p => p.ContGrpType == 3).Any() ? list.Where(p => p.ContGrpType == 3).Count() : 0 });
- res.Add(new ItemVal() { Name = "成品", Value = list.Where(p => p.ContGrpType == 1).Any() ? list.Where(p => p.ContGrpType == 1).Count() : 0 });
- var locationslists = _zhongTianCpDataService.GetLocationList();
- 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 });
- return res;
- }
- public List<WarningQtyModel> GetWarningQtyList(MySettings mySettings)
- {
- List<WarningQtyModel> res = new List<WarningQtyModel>();
- var list = _zhongTianCpDataService.GetTrayProductList();
- var qty = list.Where(p => p.ContGrpType == 2).Any() ? list.Where(p => p.ContGrpType == 2).Count() : 0;
-
- res.Add(new WarningQtyModel()
- {
- Name = "空托盘",
- Qty = qty,
- WarnQty = mySettings.MaternalCareWarning
- });
- qty = list.Where(p => p.ContGrpType == 3).Any() ? list.Where(p => p.ContGrpType == 3).Count() : 0;
- res.Add(new WarningQtyModel() { Name = "中间隔板", Qty = qty,WarnQty=mySettings.PartitionWarning });
- var locationslists = _zhongTianCpDataService.GetLocationList();
- qty = locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Any() ? locationslists.Where(p => p.StateNum == 1 && p.IsStop == 0).Count() : 0;
- res.Add(new WarningQtyModel() { Name = "空位", Qty =qty,WarnQty=mySettings.VacancyWarning });
- return res;
- }
- /// <summary>
- /// 获取产品信息
- /// </summary>
- /// <returns></returns>
- public DeliveryDetails GetProductInfoList()
- {
- var value=RedisHelper.Get("Cp:ProductTaskInfos");
- var productInfoListRequset = JsonConvert.DeserializeObject<List<ProductInfoListRequset>>(value);
- var dataInfo=_zhongTianCpDataService.GetProductInfoList(productInfoListRequset);
- return dataInfo;
- }
- }
- }
|