仓库模块_出库货物记录:init

This commit is contained in:
qianhao.xu 2024-03-22 08:54:11 +08:00
parent 2074ea2e84
commit dac58ddb77
20 changed files with 800 additions and 20 deletions

View File

@ -4,9 +4,13 @@ using ZR.Admin.WebApi.Hubs;
using ZR.Service.mes.qc.IService;
using Microsoft.AspNetCore.Mvc;
using ZR.Model.MES.qc;
using System.Collections.Generic;
namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC
{
/// <summary>
/// 生成报表
/// </summary>
[Route("mes/qc/statistics")]
public class QCStatisticsController : BaseController
{
@ -64,8 +68,12 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC
}
[HttpGet("delete_statisticsTable")]
public IActionResult DeleteStatisticsTable(string workorderid)
{
int deletenum= qcStatistics.DeleteStatisticsTable(workorderid);
return SUCCESS(deletenum);
}
}
}

View File

@ -0,0 +1,111 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
//创建时间2024-03-22
namespace ZR.Admin.WebApi.Controllers
{
/// <summary>
/// 出库货物记录表
/// </summary>
[Verify]
[Route("/mes/wm/WmGoodsOutProduction")]
public class WmGoodsOutProductionController : BaseController
{
/// <summary>
/// 出库货物记录表接口
/// </summary>
private readonly IWmGoodsOutProductionService _WmGoodsOutProductionService;
public WmGoodsOutProductionController(IWmGoodsOutProductionService WmGoodsOutProductionService)
{
_WmGoodsOutProductionService = WmGoodsOutProductionService;
}
/// <summary>
/// 查询出库货物记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:list")]
public IActionResult QueryWmGoodsOutProduction([FromQuery] WmGoodsOutProductionQueryDto parm)
{
var response = _WmGoodsOutProductionService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询出库货物记录表详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:query")]
public IActionResult GetWmGoodsOutProduction(string Id)
{
var response = _WmGoodsOutProductionService.GetInfo(Id);
var info = response.Adapt<WmGoodsOutProduction>();
return SUCCESS(info);
}
/// <summary>
/// 添加出库货物记录表
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:add")]
[Log(Title = "出库货物记录表", BusinessType = BusinessType.INSERT)]
public IActionResult AddWmGoodsOutProduction([FromBody] WmGoodsOutProductionDto parm)
{
var modal = parm.Adapt<WmGoodsOutProduction>().ToCreate(HttpContext);
var response = _WmGoodsOutProductionService.AddWmGoodsOutProduction(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新出库货物记录表
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:edit")]
[Log(Title = "出库货物记录表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateWmGoodsOutProduction([FromBody] WmGoodsOutProductionDto parm)
{
var modal = parm.Adapt<WmGoodsOutProduction>().ToUpdate(HttpContext);
var response = _WmGoodsOutProductionService.UpdateWmGoodsOutProduction(modal);
return ToResponse(response);
}
/// <summary>
/// 删除出库货物记录表
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:delete")]
[Log(Title = "出库货物记录表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteWmGoodsOutProduction(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _WmGoodsOutProductionService.Delete(idsArr);
return ToResponse(response);
}
}
}

View File

@ -135,6 +135,37 @@ namespace ZR.Admin.WebApi.Controllers
/// <summary>
/// 生成出货单的物料信息
/// </summary>
/// <returns></returns>
[HttpGet("getoutorder_matrials")]
public IActionResult Queryoutoder_matrials(string shipment_num)
{
if (shipment_num == null)
{
return SUCCESS(null);
}
List<WmMaterialQuery_print> data = _WmOutOrderService.Queryoutoder_matrials(shipment_num);
return SUCCESS(data);
}
/// <summary>
/// 生成出货单的出货计划
/// </summary>
/// <param name="shipment_num"></param>
/// <returns></returns>
[HttpGet("generate_outorderplan")]
public IActionResult Generate_outorderplan(string shipment_num)
{
if (shipment_num == null)
{
return SUCCESS(null);
}
List<WmOutOrderPlan> WmOutOrderPlanList= _WmOutOrderService.Generate_outorderplan(shipment_num);
return SUCCESS(WmOutOrderPlanList);
}
}

View File

@ -10,13 +10,13 @@
"dbConfigs": [
{
//
"Conn": "Data Source=localhost;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
//
// "Conn": "Data Source=localhost;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
//
//"Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
//
//"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
"Type": 0, // MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4,
"ConfigId": "0", //
"IsAutoCloseConnection": true
@ -26,7 +26,7 @@
//
"CodeGenDbConfig": {
//{dbName}
"Conn": "Data Source=127.0.0.1;Port=3306;User ID=root;Password=123456;Initial Catalog={dbName};",
"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog={dbName};",
"DbType": 0,
"IsAutoCloseConnection": true,
"DbName": "ZrAdmin" //

View File

@ -13,7 +13,7 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public string originalCode { get; set; }
/// <summary>
/// 批次号
/// 批次号(工单号+箱子号)
/// </summary>
public string PatchCode { get; set; }
/// <summary>

View File

@ -0,0 +1,58 @@
using System.ComponentModel.DataAnnotations;
namespace ZR.Model.MES.wms.Dto
{
/// <summary>
/// 出库货物记录表查询对象
/// </summary>
public class WmGoodsOutProductionQueryDto : PagerInfo
{
}
/// <summary>
/// 出库货物记录表输入输出对象
/// </summary>
public class WmGoodsOutProductionDto
{
[Required(ErrorMessage = "雪花id不能为空")]
public string Id { get; set; }
public string FkNowProductionId { get; set; }
public string FkOutOrderId { get; set; }
[Required(ErrorMessage = "箱子编号MES不能为空")]
public string PackageCode { get; set; }
[Required(ErrorMessage = "箱子编号(客户)不能为空")]
public string PackageCodeClient { get; set; }
public string PackageCodeOriginal { get; set; }
[Required(ErrorMessage = "库位编号不能为空")]
public string LocationCode { get; set; }
public string Partnumber { get; set; }
public int? GoodsNumLogic { get; set; }
public int? GoodsNumAction { get; set; }
public DateTime? EntryWarehouseTime { get; set; }
public DateTime? OutTime { get; set; }
public string Remark { get; set; }
public string UpdatedBy { get; set; }
public DateTime? UpdatedTime { get; set; }
public string CreatedBy { get; set; }
public DateTime? CreatedTime { get; set; }
}
}

View File

@ -52,7 +52,7 @@ namespace ZR.Model.MES.wms.Dto
/// 带库存记录的物料库存表
/// </summary>
public class WmMaterialQuery_stockQuantityDto : WmMaterialQueryDto
{
{
/// <summary>
/// 库存数量
/// </summary>
@ -61,9 +61,38 @@ namespace ZR.Model.MES.wms.Dto
/// <summary>
/// 需要出货数量
/// </summary>
public int requireOutNum { get; set; }
public int requireOutNum { get; set; }
}
/// <summary>
/// 出货单中物料信息打印
/// </summary>
public class WmMaterialQuery_print
{
/// <summary>
/// 物料号
/// </summary>
public string Partnumber { get; set; }
/// <summary>
/// 产品名称
/// </summary>
public string ProductName { get; set; }
/// <summary>
/// 需求数量
/// </summary>
public int RequireOutNum { get; set; }
//现有箱数
public int PackageNum { get; set; }
//现有零件数
public int ItemNum { get; set; }
}
/// <summary>
/// 带需要出货数量的物料库存表
@ -85,7 +114,7 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public class WmMaterialDto
{
public string Id { get; set; }
public string Partnumber { get; set; }

View File

@ -66,6 +66,8 @@ namespace ZR.Model.MES.wms.Dto
//带出货数量的物料表
public List<WmMaterialQuery_stockQuantityDto2> MaterialList { get; set; }
}
}

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugar;
namespace ZR.Model.MES.wms
{
/// <summary>
/// 出库货物记录表
/// </summary>
[SugarTable("wm_goods_out_production")]
public class WmGoodsOutProduction
{
/// <summary>
/// 雪花id
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string Id { get; set; }
/// <summary>
/// 成品库当前货物表主键
/// </summary>
[SugarColumn(ColumnName = "fk_now_production_id")]
public string FkNowProductionId { get; set; }
/// <summary>
/// 出库单号
/// </summary>
[SugarColumn(ColumnName = "fk_out_order_id")]
public string FkOutOrderId { get; set; }
/// <summary>
/// 箱子编号MES
/// </summary>
[SugarColumn(ColumnName = "package_code")]
public string PackageCode { get; set; }
/// <summary>
/// 箱子编号(客户)
/// </summary>
[SugarColumn(ColumnName = "package_code_client")]
public string PackageCodeClient { get; set; }
/// <summary>
/// 箱子编号(原始码)
/// </summary>
[SugarColumn(ColumnName = "package_code_original")]
public string PackageCodeOriginal { get; set; }
/// <summary>
/// 库位编号
/// </summary>
[SugarColumn(ColumnName = "location_code")]
public string LocationCode { get; set; }
/// <summary>
/// 零件号
/// </summary>
public string Partnumber { get; set; }
/// <summary>
/// 箱子中货物数量(理论)
/// </summary>
[SugarColumn(ColumnName = "goods_num_logic")]
public int? GoodsNumLogic { get; set; }
/// <summary>
/// 箱子中货物数量(实际)
/// </summary>
[SugarColumn(ColumnName = "goods_num_action")]
public int? GoodsNumAction { get; set; }
/// <summary>
/// 入库时间
/// </summary>
[SugarColumn(ColumnName = "entry_warehouse_time")]
public DateTime? EntryWarehouseTime { get; set; }
/// <summary>
/// 出库时间
/// </summary>
[SugarColumn(ColumnName = "out_time")]
public DateTime? OutTime { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnName = "uPDATED_BY")]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnName = "uPDATED_TIME")]
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "cREATED_BY")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "cREATED_TIME")]
public DateTime? CreatedTime { get; set; }
}
}

View File

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.wms
{
/// <summary>
/// 出库计划
///</summary>
[SugarTable("wm_out_order_plan")]
public class WmOutOrderPlan
{
/// <summary>
/// id
///</summary>
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 出库单号
///</summary>
[SugarColumn(ColumnName = "fk_out_order_id")]
public string FkOutOrderId { get; set; }
/// <summary>
/// 批次号(工单号+箱号)
///</summary>
[SugarColumn(ColumnName = "patchcode")]
public string Patchcode { get; set; }
/// <summary>
/// 物料号
///</summary>
[SugarColumn(ColumnName = "material_code")]
public string MaterialCode { get; set; }
/// <summary>
/// 所属仓库
///</summary>
[SugarColumn(ColumnName = "warehouse_code")]
public string WarehouseCode { get; set; }
/// <summary>
/// 批次箱数
///</summary>
[SugarColumn(ColumnName = "package_num")]
public int? PackageNum { get; set; }
/// <summary>
/// 批次零件数
///</summary>
[SugarColumn(ColumnName = "partnumber_num")]
public int? PartnumberNum { get; set; }
/// <summary>
/// 需求零件数
///</summary>
[SugarColumn(ColumnName = "require_num")]
public int? RequireNum { get; set; }
/// <summary>
/// 批次时间
///</summary>
[SugarColumn(ColumnName = "patchtime")]
public string Patchtime { get; set; }
/// <summary>
/// 出库顺序
///</summary>
[SugarColumn(ColumnName = "outorder")]
public int? Outorder { get; set; }
/// <summary>
/// 创建人
///</summary>
[SugarColumn(ColumnName = "CREATED_BY")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName = "CREATED_TIME")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 更新人
///</summary>
[SugarColumn(ColumnName = "UPDATED_BY")]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
///</summary>
[SugarColumn(ColumnName = "UPDATED_TIME")]
public DateTime? UpdatedTime { get; set; }
}
}

View File

@ -1398,12 +1398,12 @@ namespace ZR.Service.mes.qc
QcQualityStatisticsFirst first = new QcQualityStatisticsFirst();
first.Id = SnowFlakeSingle.Instance.NextId().ToString();
first.WorkorderId = workorderID;
ProWorkorder_v2 workorder= Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first.Color = workorder?.Colour;
ProWorkorder_v2 workorder_item = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item != null)
{
first.Color = workorder_item?.Colour;
first.FinishedPartNumber = workorder_item.FinishedPartNumber;
first.ProductDescription = workorder_item.ProductDescription;
first.RequireNumber = workorder_item.PreviousNumber;
@ -1615,13 +1615,12 @@ namespace ZR.Service.mes.qc
QcQualityStatisticsFirst first2 = new QcQualityStatisticsFirst();
first2.Id = SnowFlakeSingle.Instance.NextId().ToString();
first2.WorkorderId = workorderID;
ProWorkorder_v2 workorder2 = Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first2.Color = workorder2?.Colour;
ProWorkorder_v2 workorder_item2 = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item2 != null)
{
first2.Color = workorder_item2?.Colour;
first2.FinishedPartNumber = workorder_item2.FinishedPartNumber;
first2.ProductDescription = workorder_item2.ProductDescription;
first2.RequireNumber = workorder_item2.PreviousNumber;
@ -1839,12 +1838,13 @@ namespace ZR.Service.mes.qc
first3.WorkorderId = workorderID;
ProWorkorder_v2 workorder3 = Context.Queryable<ProWorkorder_v2>().Where(it => it.Id == first.WorkorderId).First();
first3.Color = workorder3?.Colour;
ProWorkorder_v2 workorder_item3 = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorderID).First();
if (workorder_item3 != null)
{
first3.Color = workorder_item3?.Colour;
first3.FinishedPartNumber = workorder_item3.FinishedPartNumber;
first3.ProductDescription = workorder_item3.ProductDescription;
first3.RequireNumber = workorder_item3.PreviousNumber;

View File

@ -22,5 +22,7 @@ namespace ZR.Service.mes.qc.IService
//获取 总检
(List<QcQualityStatisticsTotal>,int) GetQualityStatisticsTable_total(DateTime starttime, DateTime endTime, string workorderid, string partnumber, string product_description, string team, int pageNum, int pageSize);
#endregion
public int DeleteStatisticsTable(string workorderid);
}
}

View File

@ -13,9 +13,19 @@ using ZR.Service.mes.qc.IService;
namespace ZR.Service.mes.qc
{
/// <summary>
/// 查询报表
/// </summary>
[AppService(ServiceType = typeof(IQCStatisticsService), ServiceLifetime = LifeTime.Transient)]
public class QCStatisticsService : BaseService<QcQualityStatisticsFirst>, IQCStatisticsService
{
/// <summary>
/// 获取质量统计表 首检
/// </summary>
@ -153,5 +163,30 @@ namespace ZR.Service.mes.qc
return (data, totalNum);
}
/// <summary>
/// 删除首检,二检,三检报表
/// </summary>
/// <param name="workorderid"></param>
/// <returns></returns>
public int DeleteStatisticsTable(string workorderid)
{
int num = 0;
num = num + Context.Deleteable<QcQualityStatisticsFirst>()
.Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsAgain>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsFinal>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
num = num + Context.Deleteable<QcQualityStatisticsTotal>().Where(it => it.WorkorderId == workorderid).ExecuteCommand();
return num;
}
}
}

View File

@ -32,8 +32,6 @@ namespace ZR.Service.mes.qc
.AndIF(!string.IsNullOrEmpty(inspectionType), it => it.InspectionType == inspectionType)
.ToExpression();
return Queryable().Where(predicate).OrderBy(x => x.Order).ToList();
}
}

View File

@ -0,0 +1,24 @@
using System;
using ZR.Model;
using ZR.Model.Dto;
using System.Collections.Generic;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
namespace ZR.Service.mes.wms.IService
{
/// <summary>
/// 出库货物记录表service接口
/// </summary>
public interface IWmGoodsOutProductionService : IBaseService<WmGoodsOutProduction>
{
PagedInfo<WmGoodsOutProductionDto> GetList(WmGoodsOutProductionQueryDto parm);
WmGoodsOutProduction GetInfo(string Id);
WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction parm);
int UpdateWmGoodsOutProduction(WmGoodsOutProduction parm);
}
}

View File

@ -26,5 +26,10 @@ namespace ZR.Service.mes.wms.IService
(List<WmMaterialQuery_stockQuantityDto>, int) GetmaterialList(WmMaterialQueryDto parm);
List<WmMaterialQuery_print> Queryoutoder_matrials(string shipment_num);
List<WmOutOrderPlan> Generate_outorderplan(string shipment_num);
}
}

View File

@ -215,7 +215,7 @@ namespace ZR.Service.mes.wms
//todo 解析工单号
string workoderidid = splitstr[2].Substring(7);
resultionPackageCode.WorkoderID = workoderidid;
//todo 生产描述
//todo 生产时间
resultionPackageCode.ProductionTime="20"+ workoderidid.Substring(0,6);
//todo 解析箱子中产品数量
string product_num = splitstr[3].Substring(4);

View File

@ -0,0 +1,92 @@
using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Repository;
using System.Linq;
using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
namespace ZR.Service.Business
{
/// <summary>
/// 出库货物记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsOutProductionService : BaseService<WmGoodsOutProduction>, IWmGoodsOutProductionService
{
/// <summary>
/// 查询出库货物记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<WmGoodsOutProductionDto> GetList(WmGoodsOutProductionQueryDto parm)
{
var predicate = Expressionable.Create<WmGoodsOutProduction>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<WmGoodsOutProduction, WmGoodsOutProductionDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WmGoodsOutProduction GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateWmGoodsOutProduction(WmGoodsOutProduction model)
{
//var response = Update(w => w.Id == model.Id, it => new WmGoodsOutProduction()
//{
// PackageCode = model.PackageCode,
// PackageCodeClient = model.PackageCodeClient,
// PackageCodeOriginal = model.PackageCodeOriginal,
// LocationCode = model.LocationCode,
// Partnumber = model.Partnumber,
// GoodsNumLogic = model.GoodsNumLogic,
// GoodsNumAction = model.GoodsNumAction,
// EntryWarehouseTime = model.EntryWarehouseTime,
// OutTime = model.OutTime,
// Remark = model.Remark,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
//});
//return response;
return Update(model, true);
}
}
}

View File

@ -8,6 +8,8 @@ using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using Mapster;
using System.Collections.Generic;
using System.Data;
using JinianNet.JNTemplate.Dynamic;
namespace ZR.Service.mes.wms
{
@ -220,5 +222,188 @@ namespace ZR.Service.mes.wms
return (material_stockQuantity_list, total);
}
/// <summary>
/// 查询出货单的物料信息
/// </summary>
/// <param name="shipment_num"></param>
/// <returns></returns>
public List<WmMaterialQuery_print> Queryoutoder_matrials(string shipment_num)
{
List<WmMaterialQuery_print> stockList = Context.Queryable<WmMaterialOutorder>()
.LeftJoin<WmMaterial>((mo, m) => mo.FkMaterialId == m.Id)
.Where(mo => mo.FkOutorderId == shipment_num)
.Select((mo, m) => new WmMaterialQuery_print()
{
//物料号
Partnumber = m.Partnumber,
// 描述
ProductName = m.ProductName,
//需求零件数
RequireOutNum = mo.OuthouseNum
}).ToList();
if (stockList != null && stockList.Count > 0)
{
foreach (var stock in stockList)
{
//现有箱数
stock.PackageNum = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Count();
//现有零件数
int? num = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Sum(it => it.GoodsNumLogic);
stock.PackageNum = num ?? 0;
}
}
return stockList;
}
/// <summary>
/// 生成出货单的出货计划
/// </summary>
/// <param name="shipment_num">出货单号</param>
/// <returns></returns>
public List<WmOutOrderPlan> Generate_outorderplan(string shipment_num)
{
List<WmOutOrderPlan> wmOutOrderPlans = new List<WmOutOrderPlan>();
// 获取当前出货单下的物料信息
List<WmMaterialQuery_print> materialQuery_Prints = this.Queryoutoder_matrials(shipment_num);
if (materialQuery_Prints != null && materialQuery_Prints.Count > 0)
{
foreach (var material in materialQuery_Prints)
{
//todo 判断要出多少货 按照最早工单和批次号 进行出货(重要算法)
//1. 这个物料要出多少货
int require_num = material.RequireOutNum;
// 物料号
string partnumber = material.Partnumber;
/*
List<WmGoodsNowProduction> wmGoodsNows = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.EntryWarehouseTime).ToList();
if (wmGoodsNows != null && wmGoodsNows.Count > 0)
{
foreach (var witem in wmGoodsNows)
{
if (require_num >= witem.GoodsNumLogic)
{ // 取出同一批次下列表
string patchcode = witem.PackageCodeClient.Split("_")[0];
List<WmGoodsNowProduction> Samebatch_wmGoodsNows = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Partnumber == partnumber)
.Where(it => it.PackageCodeClient.StartsWith(patchcode)).ToList();
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
}
else
{
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
}
}
}*/
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.PackageCodeClient).ToList();
foreach(var witem in wmGoodsNowsList)
{
int accumulation_num = 0;
if (require_num>= accumulation_num)
{
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum =int.Parse( witem.PackageCodeClient.Split("_")[1] );
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
accumulation_num = accumulation_num+ witem.GoodsNumLogic??0;
}
else
{ //超了
break;
}
}
}
}
foreach (var witem in wmOutOrderPlans)
{
witem.Outorder = wmOutOrderPlans.IndexOf(witem);
}
return wmOutOrderPlans;
}
/// <summary>
/// 传入批次号 解析出时间 BNW240318007_105
/// </summary>
/// <param name="bath_code"></param>
/// <returns></returns>
private string Resolution_bath(string bath_code)
{
if (string.IsNullOrEmpty(bath_code))
{
return "";
}
string temp = bath_code.Split("_")[0];
return "20" + temp.Substring(2, 6);
}
}
}