| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using AutoMapper;
- using Newtonsoft.Json;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Security.Claims;
- using System.Text;
- using WCS.FJ.Protocol.DataStructure;
- using Wms.Screen.DataService.Impl;
- 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.Util.Extensions;
- namespace Wms.Screen.Service.Service
- {
- /// <summary>
- /// 分拣
- /// </summary>
- public class ZhongTianFjService : IZhongTianFjService
- {
- private IZhongTianFjDataService _zhongTianFjDataService;
- private IMapper _mapper;
- Dictionary<string, List<string>> _dicDevices;
- private readonly FreeRedis.RedisClient _freeRedisClient;
- static Dictionary<string, string> FjEquipsValues = new Dictionary<string, string>
- {
- { "SRM","堆垛机"}, { "RGV","RGV"}, { "Robot","机械手"}, { "Truss","桁架"},
- };
- public ZhongTianFjService(IZhongTianFjDataService zhongTianFjDataService, IMapper mapper, Dictionary<string, List<string>> dicDevices, FreeRedis.RedisClient freeRedisClient)
- {
- _zhongTianFjDataService = zhongTianFjDataService;
- _mapper = mapper;
- _dicDevices = dicDevices;
- _freeRedisClient = freeRedisClient;
- }
- public List<FJEquipDto> GetFjEquips(GetEquipsRequest reqEntity)
- {
- var real = new List<FJEquipDto>();
- var list = _zhongTianFjDataService.GetFjEquips(reqEntity);
- _dicDevices.TryGetValue(reqEntity.WarehouseCodeList[1], out var deviceslists);
- var status = _freeRedisClient.Get("Sorting:EquipmentStatus");
- if (!string.IsNullOrWhiteSpace(status) && status != "[]")
- {
- var dtolist = JsonConvert.DeserializeObject<List<BusinessDto4>>(status);
- foreach (var item in FjEquipsValues.Keys)
- {
- FJEquipDto fJEquipDto = new FJEquipDto();
- foreach (var device in deviceslists)
- {
- if (device.Contains(item))
- {
- fJEquipDto.Title = FjEquipsValues[item];
- var dto = dtolist?.FirstOrDefault(o => o.Code == device);
- fJEquipDto.Data.Add(new EquipDto()
- {
- Code = device,
- EquipState = dto != null && dto.Time.Date == DateTime.Now.Date ? EquipStatus( dto.Status) : "3",
- ResidueTask = list.Where(o => o.Device == device).Count()
- });
- }
- }
- real.Add(fJEquipDto);
- }
- }
- return real;
- }
- private string EquipStatus(string status)
- {
- if (status == "3")//报警
- {
- return "3";
- }
- else if(status == "4" || status == "5") //维护 手动
- {
- return "2";
- }
- else
- {
- return "1";
- }
- }
- public List<TaskInfoDto> GetFjTaskInfo(GetWcsTaskInfoRequest ReqEntity)
- {
- List<TaskInfoDto> taskInfoDtos = new List<TaskInfoDto>();
- taskInfoDtos = _zhongTianFjDataService.GetFjRunWcsTaskInfo(ReqEntity);
- var Len = _freeRedisClient.LLen("Packs");
- var dataPack = _freeRedisClient.LIndex<DeviceDataPack>("Packs", Len - 1);
- return taskInfoDtos;
- }
- public List<StackDto> GetFjStackInfo(GetWorkPlanBillListRequest reqEntity)
- {
- var list = _zhongTianFjDataService.GetFjStackInfo(reqEntity);
- return list;
- }
- public PageResult<ZtLocationUsageReportViewDto> GetFjLocationUsageViewList(string warehouse)
- {
- var result = new PageResult<ZtLocationUsageReportViewDto>() { ReturnValue = new List<ZtLocationUsageReportViewDto>() };
- var list = _zhongTianFjDataService.GetFjLocationUsageReportList(warehouse);
- 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<MantuoBarCodeRateDto> GetMantuoBarCodeRate(string warehouse)
- {
- return _zhongTianFjDataService.GetMantuoBarCodeRate(warehouse);
- }
- public List<BomSetGrpCurrentMaterialRateDto> GetBomSetGrpCurrentMaterialRateList(string warehouse)
- {
- return _zhongTianFjDataService.GetBomSetGrpCurrentMaterialRateList(warehouse);
- }
- public List<ItemVal> GetLocaitonList(string warehouse)
- {
- List<ItemVal> res = new List<ItemVal>();
- var list = _zhongTianFjDataService.GetLocationList(warehouse);
- 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 GetFullWeightDistRes GetInvSetGrpList()
- {
- GetFullWeightDistRes res = new GetFullWeightDistRes() { xData = new List<string>(), yData = new List<decimal>() };
- List<ItemVal> listtemp = new List<ItemVal>();
- var list = _zhongTianFjDataService.GetInvSetGrpList();
- foreach (var item in list)
- {
- res.xData.Add(item.SetGrpCode);
- res.yData.Add(item.Qty);
- }
- return res;
- }
- public GeFJHistoryTaskInfoRes GeHistoryTaskInfo(GeFJHistoryTaskInfoRequest request)
- {
- GeFJHistoryTaskInfoRes res = new GeFJHistoryTaskInfoRes();
- var lists = _zhongTianFjDataService.GeHistoryTaskInfo(request);
- string[] XAxis = new string[7]; //lists.OrderBy(o => o.CreateTime).Select(o => o.CreateTime.ToString("M-dd")).Distinct().ToArray();
- int[] Outints = new int[7];
- int[] EnterDepots = new int[7];
- int[] TransferDepots = new int[7];
- int[] SetPlate = new int[7];
- for (int i = 0; i < (request.EndTime - request.StartTime).TotalDays; i++)
- {
- var date = request.StartTime.AddDays(i);
- XAxis[i] = date.ToString("yyyy-MM-dd");
- Outints[i] = lists.Where(o => o.BusType == "车间叫料" && o.CreateTime.Date == date.Date).Sum(o => o.Count);
- EnterDepots[i] = lists.Where(o => o.BusType == "码垛入库" && o.CreateTime.Date == date.Date).Sum(o => o.Count);
- SetPlate[i] = lists.Where(o => o.Type == (int)TaskType.SetPlate && o.CreateTime.Date == date.Date).Sum(o => o.Count);
- }
- res.DateList.AddRange(XAxis);
- res.StockInList.AddRange(EnterDepots);
- res.StockOutList.AddRange(Outints);
- res.SetPlateList.AddRange(SetPlate);
- return res;
- }
- }
- }
|