104 lines
4.7 KiB
C#
104 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Extension;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Org.BouncyCastle.Crypto;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
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;
|
|
public WmsInternalTempTestService(ISqlSugarRepository<BasLocation> repo)
|
|
{
|
|
_db = repo.AsSugarClient();
|
|
}
|
|
/// <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();
|
|
|
|
}
|
|
}
|
|
}
|