| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- using AutoMapper;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Wms.Screen.DataService.Impl;
- 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.Dto;
- using System.Linq;
- using Newtonsoft.Json;
- using CSRedis;
- using WCS.Entity.Protocol.DataStructure;
- using WCS.Entity.Protocol.SRM;
- namespace Wms.Screen.Service.Service
- {
- /// <summary>
- /// 盘条
- /// </summary>
- public class ZhongTianPtService : IZhongTianPtService
- {
- private IZhongTianPtDataService _zhongTianPtDataService;
- private IMapper _mapper;
- public ZhongTianPtService(IZhongTianPtDataService zhongTianPtDataService, IMapper mapper)
- {
- _zhongTianPtDataService = zhongTianPtDataService;
- _mapper = mapper;
- }
- public List<EquipDto> GetPtEquips(GetEquipsRequest reqEntity, FreeRedis.RedisClient freeRedisClient)
- {
- var real = new List<EquipDto>();
- var list = _zhongTianPtDataService.GetPtEquips(reqEntity);
- //var tuncount = (from tun in list.GroupBy(p => p.Tunnel)
- // select new TunnelCountTemp
- // {
- // Tunnel = tun.Key,
- // Count = tun.Count()
- // }).ToList();
- using (var db = freeRedisClient.GetDatabase(13))
- {
- var srm = db.Get<DeviceDataPack>("Pt:DeviceDataPack");
- if (srm != null)
- {
- foreach (var item in srm.SRMDatas?.Datas)
- {
- EquipDto equip = new EquipDto();
- switch (item.Code)
- {
- case "SRM1":
- if ((int)item.D537.Alarm > 0)
- {
- equip.EquipState = "3";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Automatic)
- {
- equip.EquipState = "1";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Manual || item.D521.AutoStatus == SrmAutoStatus.KeepInRepair || item.D521.AutoStatus == SrmAutoStatus.SemiAutomatic)
- {
- equip.EquipState = "2";
- }
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- real.Add(equip);
- break;
- case "SRM2":
- if ((int)item.D537.Alarm > 0)
- {
- equip.EquipState = "3";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Automatic)
- {
- equip.EquipState = "1";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Manual || item.D521.AutoStatus == SrmAutoStatus.KeepInRepair || item.D521.AutoStatus == SrmAutoStatus.SemiAutomatic)
- {
- equip.EquipState = "2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- }
- equip.Code = "SRM2";
- real.Add(equip);
- break;
- case "SRM3":
- if ((int)item.D537.Alarm > 0)
- {
- equip.EquipState = "3";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Automatic)
- {
- equip.EquipState = "1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Manual || item.D521.AutoStatus == SrmAutoStatus.KeepInRepair || item.D521.AutoStatus == SrmAutoStatus.SemiAutomatic)
- {
- equip.EquipState = "2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- }
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- real.Add(equip);
- break;
- case "SRM4":
- if ((int)item.D537.Alarm > 0)
- {
- equip.EquipState = "3";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Automatic)
- {
- equip.EquipState = "1";
- }
- else if (item.D521.AutoStatus == SrmAutoStatus.Manual || item.D521.AutoStatus == SrmAutoStatus.KeepInRepair || item.D521.AutoStatus == SrmAutoStatus.SemiAutomatic)
- {
- equip.EquipState = "2";
- }
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- real.Add(equip);
- break;
- default:
- break;
- }
- }
- }
-
- }
-
- return real.OrderBy(p => p.Code).ToList();
- }
- public List<EquipDto> GetPtEquips(GetEquipsRequest reqEntity, CSRedisClient CSRedisClient)
- {
- var real = new List<EquipDto>();
- var list = _zhongTianPtDataService.GetPtEquips(reqEntity);
- //var tuncount = (from tun in list.GroupBy(p => p.Tunnel)
- // select new TunnelCountTemp
- // {
- // Tunnel = tun.Key,
- // Count = tun.Count()
- // }).ToList();
- var srm = RedisHelper.Get("Pt:SrmStatus");
- 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" || p.Tunnel == "2").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM1";
- equip.ResidueTask = list.Where(p => p.Tunnel == "1" || p.Tunnel == "2").Count();
- }
- real.Add(equip);
- break;
- case "SRM2":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3" || p.Tunnel == "4").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3" || p.Tunnel == "4").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM2";
- equip.ResidueTask = list.Where(p => p.Tunnel == "3" || p.Tunnel == "4").Count();
- }
- real.Add(equip);
- break;
- case "SRM3":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5" || p.Tunnel == "6").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5" || p.Tunnel == "6").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM3";
- equip.ResidueTask = list.Where(p => p.Tunnel == "5" || p.Tunnel == "6").Count();
- }
- real.Add(equip);
- break;
- case "SRM4":
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "7" || p.Tunnel == "8").Count();
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "7" || p.Tunnel == "8").Count();
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM4";
- equip.ResidueTask = list.Where(p => p.Tunnel == "7" || p.Tunnel == "8").Count();
- }
- real.Add(equip);
- break;
- default:
- break;
- }
- }
- return real.OrderBy(p => p.Code).ToList();
- }
- public List<TaskInfoDto> GetPtTaskInfo(GetWcsTaskInfoRequest ReqEntity)
- {
- List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
- taskInfoDtos = _zhongTianPtDataService.GetPtRunWcsTaskInfo(ReqEntity);
- return taskInfoDtos;
- }
- public List<ZTBillDto> GetPtBillList(GetWorkPlanBillListRequest reqEntity)
- {
- var list = _zhongTianPtDataService.GetPtBillList(reqEntity);
- return list;
- }
- public List<ItemVal> GetLocaitonList()
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianPtDataService.GetLocationList();
- res.Add(new ItemVal() { Name = "空", Value = list.Where(p => p.StateNum == 1).Any() ? list.Where(p => p.StateNum == 1).Count() : 0 });
- res.Add(new ItemVal() { Name = "满", Value = list.Where(p => p.StateNum == 2).Any() ? list.Where(p => p.StateNum == 2).Count() : 0 });
- 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 });
- res.Add(new ItemVal() { Name = "禁用", Value = list.Where(p => p.IsStop == 1).Any() ? list.Where(p => p.IsStop == 1).Count() : 0 });
- return res;
- }
- public GeHistoryTaskInfoRes GeHistoryTaskInfo(GeHistoryTaskInfoRequest ReqEntity)
- {
- GeHistoryTaskInfoRes res = new GeHistoryTaskInfoRes();
- var list = _zhongTianPtDataService.GeHistoryTaskInfo(ReqEntity);
- res.DateList = new List<string>() { DateTime.Now.AddDays(-6).ToShortDateString(),
- DateTime.Now.AddDays(-5).ToShortDateString(),DateTime.Now.AddDays(-4).ToShortDateString(),DateTime.Now.AddDays(-3).ToShortDateString(),
- DateTime.Now.AddDays(-2).ToShortDateString(),DateTime.Now.AddDays(-1).ToShortDateString(),DateTime.Now.ToShortDateString()};
- res.StockInList = new List<int>() {
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-6).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-6).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-5).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-5).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-4).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-4).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-3).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-3).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-2).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-2).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-1).Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.AddDays(-1).Date).Count():0 ,
- list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.Date).Any() ? list.Where(p=>p.BusType == "采购入库单" && p.EndTime.Value.Date == DateTime.Now.Date).Count():0 ,
- };
- res.StockOutList = new List<int>() {
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-6).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-6).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-5).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-5).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-4).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-4).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-3).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-3).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-2).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-2).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-1).Date).Any() ? list.Where(p=>p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.AddDays(-1).Date).Count():0 ,
- list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.Date).Any() ? list.Where(p=> p.Type == TaskType.OutDepot && p.EndTime.Value.Date == DateTime.Now.Date).Count():0 ,
- };
- return res;
- }
- public List<PTStockDto> GetInvReports()
- {
- List<PTStockDto> PTStockDtos = new List<PTStockDto>();
- var list = _zhongTianPtDataService.GetBillInvnowList();
- foreach (var item in list.GroupBy(p => new { p.MatCode, p.BoilerNo }))
- {
- PTStockDtos.Add(new PTStockDto
- {
- BoilerNo = item.Key.BoilerNo,
- MatCode = item.Key.MatCode,
- Qty = item.Count(o => !string.IsNullOrEmpty(o.BoilerNo)),
- TolWQty = item.Sum(o => o.TolWQty)
- });
- };
- return PTStockDtos.OrderBy(o => o.BoilerNo).ToList();
- }
- public PageResult<ZtLocationUsageReportViewDto> GetPtLocationUsageViewList()
- {
- var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
- var list = _zhongTianPtDataService.GetPtLocationUsageReportList();
- 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;
- }
- /// <summary>
- /// 根据物料号显示当前库存数量
- /// </summary>
- /// <returns></returns>
- public BarModelRes GetMatCodeBarDatas()
- {
- BarModelRes res = new BarModelRes();
- List<ItemVal> listtemp = new List<ItemVal>();
- var list = _zhongTianPtDataService.GetBillInvnowList().Where(p => p.InvStateCode == "InvEcecState_In");
-
-
- foreach (var item in list.GroupBy(p => p.MatCode).OrderBy(x=>x.Key))
- {
- res.xData.Add(item.Key);
- res.yData.Add(item.Count());
- }
- return res;
- }
- public BarModel2Res GetBoilerNoMatCodeQtyList()
- {
- BarModel2Res res = new BarModel2Res();
- var lists= _zhongTianPtDataService.GetBoilerNoMatCodeQtyList();
- if (lists != null && lists.Any())
- {
- res.xData = lists.Select(o => o.BoilerNo).ToList();
- res.x2Data = lists.Select(o => o.MatCode).ToList();
- res.yData = lists.Select(o => o.Qty).ToList();
- }
- return res;
- }
- }
- }
|