118 lines
4.8 KiB
C#
118 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Sockets;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Dtos.VisualDev;
|
|
using JNPF.Common.Security;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.FriendlyException;
|
|
using JNPF.Logging;
|
|
using JNPF.Systems.Entitys.System;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using JNPF.VisualDev;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using NPOI.OpenXmlFormats;
|
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
using Org.BouncyCastle.Utilities.Net;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.Common.Utils;
|
|
using Tnb.QcMgr.Entities;
|
|
using Tnb.QcMgr.Entities.Enums;
|
|
using Tnb.QcMgr.Interfaces;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.WarehouseMgr.Entities.Dto;
|
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
using Tnb.BasicData;
|
|
using Tnb.ProductionMgr.Entities.Entity;
|
|
using Tnb.WarehouseMgr.Entities.Entity;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using JNPF.VisualDev.Entitys;
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
/// <summary>
|
|
/// 其他出库
|
|
/// </summary>
|
|
[OverideVisualDev(ModuleConsts.MODULE_OtherOutstockH_ID)]
|
|
public class OtherOutstockHService : BaseWareHouseService, IOtherOutstockHService
|
|
{
|
|
private readonly IBillRullService _billRullService;
|
|
private readonly ISqlSugarClient _db;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IWareHouseService _wareHouseService;
|
|
private readonly IRunService _runService;
|
|
private readonly IVisualDevService _visualDevService;
|
|
public OtherOutstockHService(ISqlSugarRepository<WmsPurchaseH> repo, IUserManager userManager, IQcCheckPlanService qcCheckPlanService, IBillRullService billRullService,
|
|
IWareHouseService wareHouseService, IRunService runService,
|
|
IVisualDevService visualDevService)
|
|
{
|
|
_db = repo.AsSugarClient();
|
|
_userManager = userManager;
|
|
_billRullService = billRullService;
|
|
_wareHouseService = wareHouseService;
|
|
_runService = runService;
|
|
_visualDevService = visualDevService;
|
|
}
|
|
|
|
public async Task<bool> AddDetail(OtherOutstockAddDetailInput input, ISqlSugarClient dbConn = null)
|
|
{
|
|
var db = dbConn;
|
|
if (dbConn == null)
|
|
db = _db;
|
|
|
|
string Code = await _billRullService.GetBillNumber("OtherDeliverySlips");
|
|
OtherOutstockH otherOutstockH = new OtherOutstockH();
|
|
|
|
otherOutstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
|
|
otherOutstockH.outstock_type = "其它出库";
|
|
otherOutstockH.bill_code = Code;
|
|
otherOutstockH.create_id = _userManager?.User?.Id;
|
|
otherOutstockH.create_time = DateTime.Now;
|
|
otherOutstockH.department = input.department;
|
|
otherOutstockH.salesman = input.salesman;
|
|
otherOutstockH.issuance_status = "未下发";
|
|
otherOutstockH.warehouse_code = input.warehouse_code;
|
|
otherOutstockH.source_id = input.source_id;
|
|
otherOutstockH.source_bill_code = input.source_bill_code;
|
|
otherOutstockH.source_detail_id = input.source_detail_id;
|
|
|
|
List<OtherOutstockD> otherOutstockDs = new List<OtherOutstockD>();
|
|
foreach (var detail in input.details.GroupBy(g => new { g.material_id, g.material_code, g.material_name, g.unit, g.batchno }))
|
|
{
|
|
decimal? qty = detail.Sum(r => r.actual_outstock_qty);
|
|
|
|
OtherOutstockD otherOutstockD = new OtherOutstockD();
|
|
otherOutstockD.fk_id = otherOutstockH.id;
|
|
otherOutstockD.material_id = detail.Key.material_id;
|
|
otherOutstockD.material_code = detail.Key.material_code;
|
|
otherOutstockD.material_name = detail.Key.material_name;
|
|
otherOutstockD.unit = detail.Key.unit;
|
|
otherOutstockD.batchno = detail.Key.batchno;
|
|
otherOutstockD.actual_outstock_qty = qty;
|
|
otherOutstockD.rk_qty = 0;
|
|
otherOutstockD.qty = qty;
|
|
otherOutstockD.auxprop_gys = detail.ToList()[0].auxprop_gys;
|
|
otherOutstockD.auxprop_xph = detail.ToList()[0].auxprop_xph;
|
|
otherOutstockDs.Add(otherOutstockD);
|
|
}
|
|
|
|
await _db.Insertable(otherOutstockH).ExecuteCommandAsync();
|
|
await _db.Insertable(otherOutstockDs).ExecuteCommandAsync();
|
|
|
|
Logger.LogInformation($"转库单{input.source_bill_code} 生成其它出库单{Code}");
|
|
return true;
|
|
}
|
|
}
|
|
}
|