154 lines
7.1 KiB
C#
154 lines
7.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JNPF;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Extension;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Org.BouncyCastle.Crypto;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.Common.Extension;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Configs;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.WarehouseMgr.Entities.Dto.Queries;
|
|
using Tnb.WarehouseMgr.Entities.Entity;
|
|
using Tnb.WarehouseMgr.Entities.Enums;
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
public class WmsInternalTempTestService : BaseWareHouseService
|
|
{
|
|
private readonly ISqlSugarClient _db;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IConfiguration _configuration;
|
|
public WmsInternalTempTestService(ISqlSugarRepository<BasLocation> repo, IConfiguration configuration)
|
|
{
|
|
_db = repo.AsSugarClient();
|
|
_configuration = configuration;
|
|
}
|
|
/// <summary>
|
|
/// 修改列
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task UpdateColAsync()
|
|
{
|
|
List<BasLocation> list = await _db.Queryable<BasLocation>().Where(it => it.location_code.StartsWith("CP-B", StringComparison.OrdinalIgnoreCase)).OrderBy(i => i.location_code).ToListAsync();
|
|
foreach (var loc in list)
|
|
{
|
|
var input = loc.location_code.Substring(loc.location_code.Length - 2);
|
|
int num = input.Match(@"\d+").ParseToInt();
|
|
await _db.Updateable<BasLocation>().SetColumns(it => it.loc_column == num).Where(it => it.id == loc.id).ExecuteCommandAsync();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 在库物料维护
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task UpdateStkMinsync()
|
|
{
|
|
await _db.Ado.BeginTranAsync();
|
|
List<WmsStkTemp> list = await _db.Queryable<WmsStkTemp>().InnerJoin<BasMaterial>((a, b) => a.material_code == b.code)
|
|
.InnerJoin<BasLocation>((a, b, c) => a.location_code == c.location_code)
|
|
.Select((a, b, c) => new WmsStkTemp
|
|
{
|
|
material_id = b.id,
|
|
location_id = c.id,
|
|
unit_id = b.unit_id
|
|
|
|
}, true).ToListAsync();
|
|
foreach (var carrycode in list)
|
|
{
|
|
//更新载具条码及状态
|
|
WmsCarryCode wmsCarryCode = new();
|
|
|
|
|
|
wmsCarryCode.org_id = "24755469898005";
|
|
wmsCarryCode.barcode = carrycode.carry_code;
|
|
wmsCarryCode.carry_id = carrycode.carry_id;
|
|
wmsCarryCode.material_id = carrycode.material_id;
|
|
wmsCarryCode.material_code = carrycode.material_code;
|
|
wmsCarryCode.code_batch = carrycode.code_batch;
|
|
wmsCarryCode.codeqty = carrycode.codeqty;
|
|
wmsCarryCode.is_out = 0;
|
|
wmsCarryCode.location_id = carrycode.location_id;
|
|
wmsCarryCode.location_code = carrycode.location_code;
|
|
wmsCarryCode.unit_id = carrycode.unit_id;
|
|
wmsCarryCode.warehouse_id = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
|
wmsCarryCode.create_id = "25241349546773";
|
|
wmsCarryCode.material_specification = carrycode.material_specification;
|
|
wmsCarryCode.container_no = carrycode.container_no;
|
|
wmsCarryCode.create_time = DateTime.Now;
|
|
|
|
if (wmsCarryCode.carry_id != null && wmsCarryCode.location_id != null)
|
|
{
|
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = wmsCarryCode.location_id, location_code = wmsCarryCode.location_code }).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
|
|
}
|
|
else
|
|
{
|
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString() }).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
|
|
}
|
|
await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
|
//更新库位数据
|
|
if (wmsCarryCode.location_id != null)
|
|
{
|
|
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.占用).ToString() }).Where(it => it.id == wmsCarryCode.location_id).ExecuteCommandAsync();
|
|
}
|
|
|
|
}
|
|
await _db.Ado.CommitTranAsync();
|
|
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
public Task<string> GetConfigItem()
|
|
{
|
|
var locCfg = _configuration.Build<LocationConfiguration>();
|
|
return Task.FromResult(_configuration["TestLocation"]);
|
|
}
|
|
|
|
[AllowAnonymous,HttpPost]
|
|
public async Task<WmsElevatorH> ElevatorByBillCode([FromBody]ElevagorInfoQuery input)
|
|
{
|
|
var whereExpable = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>()
|
|
.And((a, b, c) => a.enabled == 1);
|
|
if (!input.taskCode.IsNullOrEmpty())
|
|
{
|
|
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.taskCode), (a, b, c) => c.bill_code == input.taskCode);
|
|
}
|
|
if (!input.endlocation_id.IsNullOrEmpty())
|
|
{
|
|
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.endlocation_id), (a, b, c) => b.location_id == input.endlocation_id);
|
|
}
|
|
if (!input.startlocation_id.IsNullOrEmpty())
|
|
{
|
|
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.startlocation_id), (a, b, c) => b.location_id == input.startlocation_id);
|
|
}
|
|
var ele = await _db.CopyNew().Queryable<WmsElevatorH>().InnerJoin<WmsElevatorD>((a, b) => a.id == b.bill_id)
|
|
.InnerJoin<WmsDistaskH>((a, b, c) => b.location_code == c.endlocation_code || b.location_code == c.startlocation_code)
|
|
.Where(whereExpable.ToExpression())
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-R", input.sourceName), (a, b, c) => c.startpoint_code == input.sourceName)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-C", input.sourceName), (a, b, c) => c.endpoint_code == input.sourceName)
|
|
.Select((a, b, c) => new WmsElevatorH
|
|
{
|
|
bill_code = c.bill_code,
|
|
device_id = a.elevator_id,
|
|
end_floor = c.end_floor
|
|
}, true)
|
|
.FirstAsync();
|
|
|
|
return ele;
|
|
}
|
|
|
|
|
|
}
|
|
}
|