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.

112 lines
3.7 KiB
C#

2 years ago
using Khd.Core.Application.Interface;
2 years ago
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Microsoft.Extensions.DependencyInjection;
2 years ago
using System;
using System.Linq;
2 years ago
using Z.EntityFramework.Plus;
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
2 years ago
.Where(c => 1 == 1)
2 years ago
.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)
{
//待取货
2 years ago
if (agvCallbackDto.method == "continue")
2 years ago
{
wcscmd.cmdStatus = 2;
wcscmd.sendFlag = 1;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.SaveChanges();
}
//已取货待放货
2 years ago
if (agvCallbackDto.method == "compeleted")
2 years ago
{
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();
}
2 years ago
2 years ago
}
reponseagvCallbackDto.code = "S";
reponseagvCallbackDto.message = "成功";
}
catch (Exception ex)
{
reponseagvCallbackDto.code = "E";
reponseagvCallbackDto.message = ex.Message;
}
2 years ago
//返回请求
reponseagvCallbackDto.reqCode = reponseagvCallbackDto.reqCode;
return reponseagvCallbackDto;
}
2 years ago
/// <summary>
/// 入库完成
/// </summary>
/// <returns></returns>
public string InWare(long taskId)
{
return "";
}
/// <summary>
/// 出库完成
/// </summary>
/// <returns></returns>
public string OutWare(long taskId)
{
return "";
}
2 years ago
}
}