141 lines
5.9 KiB
C#
141 lines
5.9 KiB
C#
using Aop.Api.Domain;
|
|
using JNPF;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Enums;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Extras.CollectiveOAuth.Models;
|
|
using JNPF.Extras.CollectiveOAuth.Utils;
|
|
using JNPF.FriendlyException;
|
|
using JNPF.Logging;
|
|
using JNPF.Systems.Interfaces.Permission;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using SqlSugar.Extensions;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.Common.Redis;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
|
using Result = Tnb.WarehouseMgr.Entities.Dto.Outputs.Result;
|
|
using Tnb.BasicData;
|
|
using Tnb.WarehouseMgr;
|
|
|
|
namespace Tnb.ProductionMgr
|
|
{
|
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
public class TimeWorkService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
|
private readonly IOrganizeService _organizeService;
|
|
private readonly IBillRullService _billRullService;
|
|
private readonly RedisData _redisData;
|
|
private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService;
|
|
|
|
public TimeWorkService(
|
|
RedisData redisData,
|
|
ISqlSugarRepository<BasMaterial> repository,
|
|
IBillRullService billRullService,
|
|
IOrganizeService organizeService,
|
|
IWmsEmptyOutstockService wmsEmptyOutstockService
|
|
)
|
|
{
|
|
_redisData = redisData;
|
|
_repository = repository;
|
|
_organizeService = organizeService;
|
|
_billRullService = billRullService;
|
|
_wmsEmptyOutstockService = wmsEmptyOutstockService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注塑空载具出库
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> EmptyCarryOutStk()
|
|
{
|
|
bool cs01 = _redisData.Get<bool>("CallCcuEmptyin_cs01");
|
|
bool c503 = _redisData.Get<bool>("CallCtuEmptyin c503");
|
|
bool cs01Flag = _redisData.Get<bool>("CallCcuEmptyin_cs01_flag");
|
|
bool c503Flag = _redisData.Get<bool>("CallCtuEmptyin c503_flag");
|
|
if (cs01 && !cs01Flag)
|
|
{
|
|
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
|
|
input.org_id = "";
|
|
input.location_code = "SSX-021-001";
|
|
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
|
|
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
|
|
input.qty = 5;
|
|
Log.Information($"【EmptyCarryOutStk】左输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
|
|
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
|
|
if (result.code == HttpStatusCode.OK)
|
|
{
|
|
Log.Information("【EmptyCarryOutStk】左输送线空箱入呼叫成功");
|
|
_redisData.Set("CallCcuEmptyin_cs01_flag", true, TimeSpan.FromMinutes(20));
|
|
}
|
|
}
|
|
|
|
if (c503 && !c503Flag)
|
|
{
|
|
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
|
|
input.org_id = "";
|
|
input.location_code = "SSX-021-003";
|
|
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
|
|
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
|
|
input.qty = 5;
|
|
Log.Information($"【EmptyCarryOutStk】右输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
|
|
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
|
|
if (result.code == HttpStatusCode.OK)
|
|
{
|
|
Log.Information("【EmptyCarryOutStk】右输送线空箱入呼叫成功");
|
|
_redisData.Set("CallCtuEmptyin c503_flag", true, TimeSpan.FromMinutes(20));
|
|
}
|
|
}
|
|
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> FixedPointDelivery()
|
|
{
|
|
bool value = _redisData.Get<bool>("DB100.132.0");
|
|
bool valueFlag = _redisData.Get<bool>("DB100.132.0_flag");
|
|
if (value && !valueFlag)
|
|
{
|
|
var db = _repository.AsSugarClient();
|
|
Dictionary<String, Object> postData = new Dictionary<string, object>();
|
|
|
|
|
|
Dictionary<string, object> header = new()
|
|
{
|
|
["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
|
};
|
|
BasFactoryConfig config = await db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
|
|
string sendResult = HttpUtils.RequestPost($"{config.value}/api/visualdev/OnlineDev/{ModuleConsts.MODULE_WMSDELIVERYPDA_ID}", JsonConvert.SerializeObject(postData), header);
|
|
|
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
|
if(authResponse.code == 200 && authResponse.data.ObjToBool())
|
|
{
|
|
Log.Information("【FixedPointDelivery】注塑定点配送成功");
|
|
_redisData.Set("DB100.132.0_flag", true, TimeSpan.FromMinutes(20));
|
|
}
|
|
else
|
|
{
|
|
Log.Information(sendResult);
|
|
}
|
|
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
}
|
|
} |