You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.6 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Khd.Core.Application.Interface;
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Masuit.Tools;
using Masuit.Tools.Logging;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.DependencyInjection;
using Z.EntityFramework.Plus;
2 years ago
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
2 years ago
namespace Khd.Core.Application
{
public class WcsTaskApplication : IWcsTaskApplication
{
private readonly DefaultDbContext _dbContext;
public WcsTaskApplication(IServiceProvider serviceProvider)
{
_dbContext = serviceProvider.GetService<DefaultDbContext>();
}
public WcsTask Get(int id)
{
var entity = _dbContext.WcsTask
.Where(c => 1== 1)
.FirstOrDefault();
return entity;
}
public WcsTask Add(WcsTask model)
{
var entity = _dbContext.Add(model);
_dbContext.SaveChanges();
return entity.Entity;
}
public WcsTask Update(WcsTask model)
{
var list = _dbContext.WcsTask.Where(t => t.objid == model.objid).Update(a => model);
return model;
}
/// <summary>
/// 接收agv接收任务通知接口
/// </summary>
/// <param name="agvCallbackDto"></param>
/// <returns></returns>
public ReponseagvCallbackDto AgvCallback(agvCallbackDto agvCallbackDto)
{
ReponseagvCallbackDto reponseagvCallbackDto = new ReponseagvCallbackDto();
2 years ago
try
{
//处理逻辑
var wcscmd = _dbContext.WcsCmd.Where(t => t.objid == Convert.ToInt64(agvCallbackDto.taskCode)).FirstOrDefault();
if (wcscmd != null)
{
//待取货
if (agvCallbackDto.method == "")
{
wcscmd.cmdStatus = 2;
wcscmd.sendFlag = 1;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.SaveChanges();
}
//已取货待放货
if (agvCallbackDto.method == "")
{
wcscmd.cmdStatus = 3;
wcscmd.sendFlag = 1;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.SaveChanges();
2 years ago
2 years ago
var list = _dbContext.WcsTask.Where(t => t.objid == wcscmd.taskId).Update(a => new WcsTask() { currPointNo = wcscmd.equipmentNo });
}
//放货完成
if (agvCallbackDto.method == "outbin")
{
wcscmd.cmdStatus = 5;
wcscmd.sendFlag = 1;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.SaveChanges();
}
}
reponseagvCallbackDto.code = "S";
reponseagvCallbackDto.message = "成功";
}
catch (Exception ex)
{
reponseagvCallbackDto.code = "E";
reponseagvCallbackDto.message = ex.Message;
}
2 years ago
//返回请求
reponseagvCallbackDto.reqCode = reponseagvCallbackDto.reqCode;
return reponseagvCallbackDto;
}
}
}