197 lines
8.4 KiB
C#
197 lines
8.4 KiB
C#
using Aop.Api.Domain;
|
|
using JNPF;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Enums;
|
|
using JNPF.Common.Extension;
|
|
using JNPF.Common.Security;
|
|
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;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> test()
|
|
{
|
|
var db = _repository.AsSugarClient();
|
|
|
|
await db.Ado.BeginTranAsync();
|
|
BasUnit basUnit = new BasUnit();
|
|
basUnit.id = SnowflakeIdHelper.NextId();
|
|
basUnit.unit_name = "aaa";
|
|
basUnit.unit_code = "bbb";
|
|
await db.Insertable(basUnit).ExecuteCommandAsync();
|
|
|
|
await db.Ado.CommitTranAsync();
|
|
|
|
await db.Ado.BeginTranAsync();
|
|
BasUnit basUnit2 = new BasUnit();
|
|
basUnit2.id = SnowflakeIdHelper.NextId();
|
|
basUnit2.unit_name = "ccc";
|
|
basUnit2.unit_code = "ddd";
|
|
await db.Insertable(basUnit2).ExecuteCommandAsync();
|
|
|
|
await db.Ado.CommitTranAsync();
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注塑空载具出库
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> EmptyCarryOutStk()
|
|
{
|
|
bool? cs01 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS01");
|
|
bool? cs03 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS03");
|
|
bool cs01Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS01_flag");
|
|
bool cs03Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS03_flag");
|
|
if (cs01==true && !cs01Flag)
|
|
{
|
|
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
|
|
HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-left");
|
|
}
|
|
|
|
if (cs03==true && !cs03Flag)
|
|
{
|
|
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
|
|
HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-right");
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> EmptyCarryOutStkLeft()
|
|
{
|
|
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
|
|
input.org_id = WmsWareHouseConst.AdministratorOrgId;
|
|
input.location_code = "SSX-021-001";
|
|
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
|
|
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
|
|
input.qty = 1;
|
|
input.create_id = WmsWareHouseConst.AdministratorUserId;
|
|
Log.Information($"【EmptyCarryOutStk】左输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
|
|
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
|
|
if (result.code == HttpStatusCode.OK)
|
|
{
|
|
Log.Information("【EmptyCarryOutStk】左输送线空箱入呼叫成功");
|
|
//_redisData.Set("YTCS_CallCtuEmptyIn_CS01_flag", true, TimeSpan.FromMinutes(20));
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> EmptyCarryOutStkRight()
|
|
{
|
|
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
|
|
input.org_id = WmsWareHouseConst.AdministratorOrgId;
|
|
input.location_code = "SSX-021-003";
|
|
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
|
|
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
|
|
input.qty = 1;
|
|
input.create_id = WmsWareHouseConst.AdministratorUserId;
|
|
Log.Information($"【EmptyCarryOutStk】右输送线空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
|
|
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
|
|
if (result.code == HttpStatusCode.OK)
|
|
{
|
|
Log.Information("【EmptyCarryOutStk】右输送线空箱入呼叫成功");
|
|
//_redisData.Set("YTCS_CallCtuEmptyIn_CS03_flag", true, TimeSpan.FromMinutes(20));
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> FixedPointDelivery()
|
|
{
|
|
bool? value = await _redisData.TryGetValueByKeyField<bool?>("hxjA", "DB100.132.0");
|
|
bool valueFlag = _redisData.Get<bool>("hxjA_DB100.132.0_flag");
|
|
if (value==true && !valueFlag)
|
|
{
|
|
bool? cs01 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS01");
|
|
bool? cs03 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS03");
|
|
string startLocationCode = cs01==false ? "SSX-021-001" : cs03==false ? "SSX-021-003" : "";
|
|
if (startLocationCode.IsEmpty())
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
} |