| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- using AutoMapper;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using Wms.Screen.DataService.Interface;
- using Wms.Screen.Dto;
- using Wms.Screen.Dto.ZhongTian;
- using Wms.Screen.Dto.ZhongTian.Request;
- using Wms.Screen.Dto.ZhongTian.Response;
- using Wms.Screen.Service.IService;
- using Wms.Screen.SqlSugar.ZhongTian;
- using Wms.Screen.Util.Extensions;
- namespace Wms.Screen.Service.Service
- {
- public class ZhongTianHjService : IZhongTianHjService
- {
- private readonly IZhongTianHjDataService _zhongTianHjDataService;
- private readonly IMapper _mapper;
- public ZhongTianHjService(IMapper mapper, IZhongTianHjDataService zhongTianHjDataService)
- {
- _mapper = mapper;
- _zhongTianHjDataService = zhongTianHjDataService;
- }
- public List<EquipDto> GetHjEquips(GetEquipsRequest reqEntity)
- {
- var real = new List<EquipDto>();
- var list = _zhongTianHjDataService.GetHjEquips(reqEntity);
- var tun1 = list.Where(p => p.Tunnel == "1").Count();
- var tun2 = list.Where(p => p.Tunnel == "2").Count();
- var tun3 = list.Where(p => p.Tunnel == "3").Count();
- var srm = RedisHelper.Get("Alloy:SrmStatus");
- var msgdto = JsonConvert.DeserializeObject<List<SRMEquipDto>>(srm);
- foreach (var item in msgdto)
- {
- EquipDto equip = new EquipDto();
- if (item.Item1 == "SRM3")
- {
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM3";
- equip.ResidueTask = tun3;
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM3";
- equip.ResidueTask = tun3;
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM3";
- equip.ResidueTask = tun3;
- }
- }
- else if (item.Item1 == "SRM2")
- {
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM2";
- equip.ResidueTask = tun2;
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM2";
- equip.ResidueTask = tun2;
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM2";
- equip.ResidueTask = tun2;
- }
- }
- else if (item.Item1 == "SRM1")
- {
- if (item.Item2 == "Automatic")
- {
- equip.EquipState = "1";
- equip.Code = "SRM1";
- equip.ResidueTask = tun1;
- }
- else if (item.Item2 == "Manual")
- {
- equip.EquipState = "2";
- equip.Code = "SRM1";
- equip.ResidueTask = tun1;
- }
- else
- {
- equip.EquipState = "3";
- equip.Code = "SRM1";
- equip.ResidueTask = tun1;
- }
- }
- else
- {
- continue;
- }
- real.Add(equip);
- }
- return real;
- }
- /// <summary>
- /// 获取合金任务货位分布
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public List<ItemVal> GetLocaitonList()
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianHjDataService.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;
- }
- /// <summary>
- /// 获取合金空满轮分布
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public List<ItemVal> GetEmptyFullDist()
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianHjDataService.GetBillInvnowList();
- 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 == 1).Any() ? list.Where(p => p.ContGrpType == 1).Count() : 0 });
- return res;
- }
- public List<ItemVal> GetTunelCountList()
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianHjDataService.GetTunelCountList();
- foreach (var item in list)
- {
- if (item.Tunnel.HasValue)
- {
- res.Add(new ItemVal()
- {
- Name = item.Tunnel + "巷道" + (item.ContGrpType == 2 ? "空轮" : "满轮"),
- Value = item.Qty
- });
- }
- }
- return res;
- }
- /// <summary>
- /// 获取历史任务信息
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public GeHistoryTaskInfoRes GeHistoryTaskInfo(GeHistoryTaskInfoRequest ReqEntity)
- {
- GeHistoryTaskInfoRes res = new GeHistoryTaskInfoRes();
- var list = _zhongTianHjDataService.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.AddTime.Date == DateTime.Now.AddDays(-6).Date).Any() ? list.Where(p=>p.BusType == "镀铜一楼取满" && p.AddTime.Date == DateTime.Now.AddDays(-6).Date).Count():0 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- };
- res.StockOutList = new List<int>() {
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- 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 ,
- };
- return res;
- }
- /// <summary>
- /// 获取合金任务信息
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public List<TaskInfoDto> GetHjTaskInfo(GetWcsTaskInfoRequest ReqEntity)
- {
- List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
- taskInfoDtos = _zhongTianHjDataService.GetHjRunWcsTaskInfo(ReqEntity);
- return taskInfoDtos;
- }
- /// <summary>
- /// 获取合金重量轮分布
- /// </summary>
- /// <param name="ReqEntity"></param>
- /// <returns></returns>
- public GetFullWeightDistRes GetFullWeightDist()
- {
- GetFullWeightDistRes res = new GetFullWeightDistRes() { xData = new List<string>(), yData = new List<decimal>() };
- List<ItemVal> listtemp = new List<ItemVal>();
- var list = _zhongTianHjDataService.GetBillInvnowList().Where(p => p.ContGrpType == 1 && p.InvStateCode == "InvEcecState_In");
- foreach (var item in list.GroupBy(p => p.MatCode))
- {
- res.xData.Add(item.Key);
- res.yData.Add(item.Sum(q => q.NetWQty));
- }
- return res;
- }
- public List<ZTBillDto> GetHjBillList(GetWorkPlanBillListRequest reqEntity)
- {
- var list = _zhongTianHjDataService.GetHjBillList(reqEntity);
- if (list.Any())
- {
- foreach (var item in list)
- {
- if (item.TypeCode == DocType.DocType_HJ_CopperProductStockIn.GetHashCode().ToString())
- {
- item.TypeCode = DocType.DocType_HJ_CopperProductStockIn.GetDescription();
- }
- else if (item.TypeCode == DocType.DocType_HJ_WetLinePickMaterApply.GetHashCode().ToString())
- {
- item.TypeCode = DocType.DocType_HJ_WetLinePickMaterApply.GetDescription();
- }
- else if (item.TypeCode == DocType.DocType_HJ_WetLineBack.GetHashCode().ToString())
- {
- item.TypeCode = DocType.DocType_HJ_WetLineBack.GetDescription();
- }
- else if (item.TypeCode == DocType.DocType_HJ_WetLineLeft.GetHashCode().ToString())
- {
- item.TypeCode = DocType.DocType_HJ_WetLineLeft.GetDescription();
- }
- }
- }
- return list;
- }
- public Result<int> GetEmtpyLocationCountByTunnel(List<string> tunnels, int size)
- {
- var result = new Result<int>() { ReturnValue = 0 };
- //var model = _zhongTianHjDataService.GetEmtpyLocationCountByTunnel(tunnels, size);
- //result.ReturnValue = model;
- return result;
- }
- public Result<int> GetRuningInTaskCountByTunnel(int tunnel, string warehousecode, int size)
- {
- var result = new Result<int>() { ReturnValue = 0 };
- var model = _zhongTianHjDataService.GetRuningInTaskCountByTunnel(tunnel, warehousecode, size);
- if (model != null)
- {
- result.ReturnValue = model;
- }
- return result;
- }
- public PageResult<ZtLocationUsageReportViewDto> GetHjLocationUsageViewList()
- {
- var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
- //查询巷道的禁用/启用信息
- //var configTunnelList = _zhongTianHjDataService.GetTunnelConfigList(new DetailCodeRequest() { Code = "" })?.ReturnValue;
- var list = _zhongTianHjDataService.GetHjLocationUsageReportList();
- //if (configTunnelList != null && configTunnelList.Any())
- //{
- // //更新巷道状态
- // list.ForEach(s =>
- // {
- // var conf = configTunnelList.Where(m => m.WarehouseName == s.WarehouseName && m.Tunnel == s.Tunnel.Substring(0, 1)).FirstOrDefault();
- // if (conf != null)
- // {
- // s.InStates = conf.InStates;
- // s.OutStates = conf.OutStates;
- // }
- // });
- //}
- 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;
- }
- }
- }
|