diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs index 704b502b..c28e2425 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs @@ -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 { + /// + /// 生成报表 + /// [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); + } } } diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs new file mode 100644 index 00000000..0a366b0b --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs @@ -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 +{ + /// + /// 出库货物记录表 + /// + [Verify] + [Route("/mes/wm/WmGoodsOutProduction")] + public class WmGoodsOutProductionController : BaseController + { + /// + /// 出库货物记录表接口 + /// + private readonly IWmGoodsOutProductionService _WmGoodsOutProductionService; + + public WmGoodsOutProductionController(IWmGoodsOutProductionService WmGoodsOutProductionService) + { + _WmGoodsOutProductionService = WmGoodsOutProductionService; + } + + /// + /// 查询出库货物记录表列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:list")] + public IActionResult QueryWmGoodsOutProduction([FromQuery] WmGoodsOutProductionQueryDto parm) + { + var response = _WmGoodsOutProductionService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询出库货物记录表详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:query")] + public IActionResult GetWmGoodsOutProduction(string Id) + { + var response = _WmGoodsOutProductionService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加出库货物记录表 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:add")] + [Log(Title = "出库货物记录表", BusinessType = BusinessType.INSERT)] + public IActionResult AddWmGoodsOutProduction([FromBody] WmGoodsOutProductionDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _WmGoodsOutProductionService.AddWmGoodsOutProduction(modal); + + return SUCCESS(response); + } + + /// + /// 更新出库货物记录表 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:wmgoodsoutproduction:edit")] + [Log(Title = "出库货物记录表", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateWmGoodsOutProduction([FromBody] WmGoodsOutProductionDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _WmGoodsOutProductionService.UpdateWmGoodsOutProduction(modal); + + return ToResponse(response); + } + + /// + /// 删除出库货物记录表 + /// + /// + [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); + } + + + + + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs index bbb11512..95c6631d 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmOutOrderController.cs @@ -135,6 +135,37 @@ namespace ZR.Admin.WebApi.Controllers + /// + /// 生成出货单的物料信息 + /// + /// + [HttpGet("getoutorder_matrials")] + public IActionResult Queryoutoder_matrials(string shipment_num) + { + if (shipment_num == null) + { + return SUCCESS(null); + + } + List data = _WmOutOrderService.Queryoutoder_matrials(shipment_num); + return SUCCESS(data); + } + /// + /// 生成出货单的出货计划 + /// + /// + /// + [HttpGet("generate_outorderplan")] + public IActionResult Generate_outorderplan(string shipment_num) + { + if (shipment_num == null) + { + return SUCCESS(null); + } + List WmOutOrderPlanList= _WmOutOrderService.Generate_outorderplan(shipment_num); + + return SUCCESS(WmOutOrderPlanList); + } } diff --git a/ZR.Admin.WebApi/appsettings.development.json b/ZR.Admin.WebApi/appsettings.development.json index 820527f3..cb3bc60b 100644 --- a/ZR.Admin.WebApi/appsettings.development.json +++ b/ZR.Admin.WebApi/appsettings.development.json @@ -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 = 3,PgSql = 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" //代码生成默认连接数据库 diff --git a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-出库货物记录表-0322083827.zip b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-出库货物记录表-0322083827.zip new file mode 100644 index 00000000..5950f51e Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-出库货物记录表-0322083827.zip differ diff --git a/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs index a59d0d8a..2c8d30de 100644 --- a/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs +++ b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs @@ -13,7 +13,7 @@ namespace ZR.Model.MES.wms.Dto /// public string originalCode { get; set; } /// - /// 批次号 + /// 批次号(工单号+箱子号) /// public string PatchCode { get; set; } /// diff --git a/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs b/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs new file mode 100644 index 00000000..8094957d --- /dev/null +++ b/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs @@ -0,0 +1,58 @@ +using System.ComponentModel.DataAnnotations; + +namespace ZR.Model.MES.wms.Dto +{ + /// + /// 出库货物记录表查询对象 + /// + public class WmGoodsOutProductionQueryDto : PagerInfo + { + } + + /// + /// 出库货物记录表输入输出对象 + /// + 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; } + + + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs index 5dfe2ab2..3a8ba13a 100644 --- a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs +++ b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs @@ -52,7 +52,7 @@ namespace ZR.Model.MES.wms.Dto /// 带库存记录的物料库存表 /// public class WmMaterialQuery_stockQuantityDto : WmMaterialQueryDto - { + { /// /// 库存数量 /// @@ -61,9 +61,38 @@ namespace ZR.Model.MES.wms.Dto /// /// 需要出货数量 /// - public int requireOutNum { get; set; } + public int requireOutNum { get; set; } } + /// + /// 出货单中物料信息打印 + /// + public class WmMaterialQuery_print + { + + /// + /// 物料号 + /// + public string Partnumber { get; set; } + /// + /// 产品名称 + /// + public string ProductName { get; set; } + /// + /// 需求数量 + /// + public int RequireOutNum { get; set; } + + //现有箱数 + public int PackageNum { get; set; } + + //现有零件数 + public int ItemNum { get; set; } + + + } + + /// /// 带需要出货数量的物料库存表 @@ -85,7 +114,7 @@ namespace ZR.Model.MES.wms.Dto /// public class WmMaterialDto { - + public string Id { get; set; } public string Partnumber { get; set; } diff --git a/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs b/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs index 71c71885..ba220f43 100644 --- a/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs +++ b/ZR.Model/MES/wms/Dto/WmOutOrderDto.cs @@ -66,6 +66,8 @@ namespace ZR.Model.MES.wms.Dto //带出货数量的物料表 public List MaterialList { get; set; } - } + + + } \ No newline at end of file diff --git a/ZR.Model/MES/wms/WmGoodsOutProduction.cs b/ZR.Model/MES/wms/WmGoodsOutProduction.cs new file mode 100644 index 00000000..8ce77552 --- /dev/null +++ b/ZR.Model/MES/wms/WmGoodsOutProduction.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SqlSugar; +namespace ZR.Model.MES.wms +{ + /// + /// 出库货物记录表 + /// + [SugarTable("wm_goods_out_production")] + public class WmGoodsOutProduction + { + /// + /// 雪花id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 成品库当前货物表主键 + /// + [SugarColumn(ColumnName = "fk_now_production_id")] + public string FkNowProductionId { get; set; } + + /// + /// 出库单号 + /// + [SugarColumn(ColumnName = "fk_out_order_id")] + public string FkOutOrderId { get; set; } + + /// + /// 箱子编号(MES) + /// + [SugarColumn(ColumnName = "package_code")] + public string PackageCode { get; set; } + + /// + /// 箱子编号(客户) + /// + [SugarColumn(ColumnName = "package_code_client")] + public string PackageCodeClient { get; set; } + + /// + /// 箱子编号(原始码) + /// + [SugarColumn(ColumnName = "package_code_original")] + public string PackageCodeOriginal { get; set; } + + /// + /// 库位编号 + /// + [SugarColumn(ColumnName = "location_code")] + public string LocationCode { get; set; } + + /// + /// 零件号 + /// + public string Partnumber { get; set; } + + /// + /// 箱子中货物数量(理论) + /// + [SugarColumn(ColumnName = "goods_num_logic")] + public int? GoodsNumLogic { get; set; } + + /// + /// 箱子中货物数量(实际) + /// + [SugarColumn(ColumnName = "goods_num_action")] + public int? GoodsNumAction { get; set; } + + /// + /// 入库时间 + /// + [SugarColumn(ColumnName = "entry_warehouse_time")] + public DateTime? EntryWarehouseTime { get; set; } + + /// + /// 出库时间 + /// + [SugarColumn(ColumnName = "out_time")] + public DateTime? OutTime { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "uPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "cREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "cREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/wms/WmOutOrderPlan.cs b/ZR.Model/MES/wms/WmOutOrderPlan.cs new file mode 100644 index 00000000..a82e0b7b --- /dev/null +++ b/ZR.Model/MES/wms/WmOutOrderPlan.cs @@ -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 +{ + /// + /// 出库计划 + /// + [SugarTable("wm_out_order_plan")] + public class WmOutOrderPlan + { + /// + /// id + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + /// + /// 出库单号 + /// + [SugarColumn(ColumnName = "fk_out_order_id")] + public string FkOutOrderId { get; set; } + /// + /// 批次号(工单号+箱号) + /// + [SugarColumn(ColumnName = "patchcode")] + public string Patchcode { get; set; } + /// + /// 物料号 + /// + [SugarColumn(ColumnName = "material_code")] + public string MaterialCode { get; set; } + /// + /// 所属仓库 + /// + [SugarColumn(ColumnName = "warehouse_code")] + public string WarehouseCode { get; set; } + /// + /// 批次箱数 + /// + [SugarColumn(ColumnName = "package_num")] + public int? PackageNum { get; set; } + /// + /// 批次零件数 + /// + [SugarColumn(ColumnName = "partnumber_num")] + public int? PartnumberNum { get; set; } + /// + /// 需求零件数 + /// + [SugarColumn(ColumnName = "require_num")] + public int? RequireNum { get; set; } + /// + /// 批次时间 + /// + [SugarColumn(ColumnName = "patchtime")] + public string Patchtime { get; set; } + /// + /// 出库顺序 + /// + [SugarColumn(ColumnName = "outorder")] + public int? Outorder { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + } +} diff --git a/ZR.Service/mes/qc/FirstFQCService.cs b/ZR.Service/mes/qc/FirstFQCService.cs index 2a28a9d4..e08c5e29 100644 --- a/ZR.Service/mes/qc/FirstFQCService.cs +++ b/ZR.Service/mes/qc/FirstFQCService.cs @@ -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().Where(it => it.Id == first.WorkorderId).First(); - first.Color = workorder?.Colour; + ProWorkorder_v2 workorder_item = Context.Queryable().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().Where(it => it.Id == first.WorkorderId).First(); - first2.Color = workorder2?.Colour; + ProWorkorder_v2 workorder_item2 = Context.Queryable().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().Where(it => it.Id == first.WorkorderId).First(); - first3.Color = workorder3?.Colour; + ProWorkorder_v2 workorder_item3 = Context.Queryable().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; diff --git a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs index 34147448..70dc7d7f 100644 --- a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs +++ b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs @@ -22,5 +22,7 @@ namespace ZR.Service.mes.qc.IService //获取 总检 (List,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); } } diff --git a/ZR.Service/mes/qc/QCStatisticsService.cs b/ZR.Service/mes/qc/QCStatisticsService.cs index 2dfb866e..d962972f 100644 --- a/ZR.Service/mes/qc/QCStatisticsService.cs +++ b/ZR.Service/mes/qc/QCStatisticsService.cs @@ -13,9 +13,19 @@ using ZR.Service.mes.qc.IService; namespace ZR.Service.mes.qc { + /// + /// 查询报表 + /// [AppService(ServiceType = typeof(IQCStatisticsService), ServiceLifetime = LifeTime.Transient)] public class QCStatisticsService : BaseService, IQCStatisticsService { + + + + + + + /// /// 获取质量统计表 首检 /// @@ -153,5 +163,30 @@ namespace ZR.Service.mes.qc return (data, totalNum); } + + /// + /// 删除首检,二检,三检报表 + /// + /// + /// + public int DeleteStatisticsTable(string workorderid) + { + int num = 0; + num = num + Context.Deleteable() + .Where(it => it.WorkorderId == workorderid).ExecuteCommand(); + + + num = num + Context.Deleteable().Where(it => it.WorkorderId == workorderid).ExecuteCommand(); + + + num = num + Context.Deleteable().Where(it => it.WorkorderId == workorderid).ExecuteCommand(); + + + num = num + Context.Deleteable().Where(it => it.WorkorderId == workorderid).ExecuteCommand(); + + + return num; + + } } } diff --git a/ZR.Service/mes/qc/QcinspectionItemService.cs b/ZR.Service/mes/qc/QcinspectionItemService.cs index c4bf573f..638dc6ae 100644 --- a/ZR.Service/mes/qc/QcinspectionItemService.cs +++ b/ZR.Service/mes/qc/QcinspectionItemService.cs @@ -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(); } } diff --git a/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs b/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs new file mode 100644 index 00000000..7b119d3a --- /dev/null +++ b/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs @@ -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 +{ + /// + /// 出库货物记录表service接口 + /// + public interface IWmGoodsOutProductionService : IBaseService + { + PagedInfo GetList(WmGoodsOutProductionQueryDto parm); + + WmGoodsOutProduction GetInfo(string Id); + + WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction parm); + + int UpdateWmGoodsOutProduction(WmGoodsOutProduction parm); + + } +} diff --git a/ZR.Service/mes/wms/IService/IWmOutOrderService.cs b/ZR.Service/mes/wms/IService/IWmOutOrderService.cs index e7e2c98e..fe5045fb 100644 --- a/ZR.Service/mes/wms/IService/IWmOutOrderService.cs +++ b/ZR.Service/mes/wms/IService/IWmOutOrderService.cs @@ -26,5 +26,10 @@ namespace ZR.Service.mes.wms.IService (List, int) GetmaterialList(WmMaterialQueryDto parm); + + List Queryoutoder_matrials(string shipment_num); + + List Generate_outorderplan(string shipment_num); + } } diff --git a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs index 9cfc528f..74427e2d 100644 --- a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs @@ -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); diff --git a/ZR.Service/mes/wms/WmGoodsOutProductionService.cs b/ZR.Service/mes/wms/WmGoodsOutProductionService.cs new file mode 100644 index 00000000..d062e0ee --- /dev/null +++ b/ZR.Service/mes/wms/WmGoodsOutProductionService.cs @@ -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 +{ + /// + /// 出库货物记录表Service业务层处理 + /// + [AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)] + public class WmGoodsOutProductionService : BaseService, IWmGoodsOutProductionService + { + /// + /// 查询出库货物记录表列表 + /// + /// + /// + public PagedInfo GetList(WmGoodsOutProductionQueryDto parm) + { + var predicate = Expressionable.Create(); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public WmGoodsOutProduction GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加出库货物记录表 + /// + /// + /// + public WmGoodsOutProduction AddWmGoodsOutProduction(WmGoodsOutProduction model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改出库货物记录表 + /// + /// + /// + 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); + } + + } +} \ No newline at end of file diff --git a/ZR.Service/mes/wms/WmOutOrderService.cs b/ZR.Service/mes/wms/WmOutOrderService.cs index 92d9850a..c59db9fe 100644 --- a/ZR.Service/mes/wms/WmOutOrderService.cs +++ b/ZR.Service/mes/wms/WmOutOrderService.cs @@ -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); } + + + + /// + /// 查询出货单的物料信息 + /// + /// + /// + public List Queryoutoder_matrials(string shipment_num) + { + + List stockList = Context.Queryable() + .LeftJoin((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().Where(it => it.Partnumber == shipment_num).Count(); + + //现有零件数 + int? num = Context.Queryable().Where(it => it.Partnumber == shipment_num).Sum(it => it.GoodsNumLogic); + stock.PackageNum = num ?? 0; + } + } + + + + return stockList; + + + + } + + /// + /// 生成出货单的出货计划 + /// + /// 出货单号 + /// + public List Generate_outorderplan(string shipment_num) + { + + List wmOutOrderPlans = new List(); + // 获取当前出货单下的物料信息 + List 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 wmGoodsNows = Context.Queryable().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 Samebatch_wmGoodsNows = Context.Queryable() + .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 wmGoodsNowsList = Context.Queryable().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; + + } + + /// + /// 传入批次号 解析出时间 BNW240318007_105 + /// + /// + /// + 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); + } } } \ No newline at end of file