diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
index 77339a02..edab4b6d 100644
--- a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
@@ -5,6 +5,7 @@ using ZR.Model.Dto;
using ZR.Model.System;
using ZR.Service.System.IService;
+
namespace ZR.Admin.WebApi.Controllers
{
///
diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs
index b074b93e..b3443d4e 100644
--- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs
@@ -102,11 +102,14 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro
public IActionResult ReleaseProduction(string id)
{
- int data = proWorkorderService.ReleaseProduction(id);
+ int data = proWorkorderService.ReleaseProduction(id, HttpContext);
return ToResponse(new ApiResult(200, "success", data));
}
+
+
+
///
/// 对当前的,排产工单排序
///
diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanController.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanController.cs
index 89f4d2f1..8138212b 100644
--- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanController.cs
@@ -8,8 +8,6 @@ using ZR.Service.MES.md;
namespace ZR.Admin.WebApi.Controllers.MES.pro
{
- //
- //
[Route("mes/pro/workplan")]
public class ProWorkplanController : BaseController
@@ -156,6 +154,7 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro
// 计划数>0 计划数要大于等于当前工单总数
if(countWorkplan > 0 && (countWorkplan>= countWorkorder))
{
+ proWorkorder.Partnumber = lstWorkplan[0].Partnumber;
proWorkorder.ToCreate(HttpContext);
data = proWorkplanService.AddWorkorder(proWorkorder);
}
diff --git a/ZR.Admin.WebApi/Controllers/mes/wm/MaterialRequisitionController.cs b/ZR.Admin.WebApi/Controllers/mes/wm/MaterialRequisitionController.cs
new file mode 100644
index 00000000..bf97a179
--- /dev/null
+++ b/ZR.Admin.WebApi/Controllers/mes/wm/MaterialRequisitionController.cs
@@ -0,0 +1,48 @@
+using Infrastructure.Extensions;
+using JinianNet.JNTemplate;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.IdentityModel.Tokens;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.Text.Json;
+using ZR.Admin.WebApi.Extensions;
+using ZR.Model.MES.wm;
+using ZR.Service.mes.pro;
+using ZR.Service.mes.wm.IService;
+
+namespace ZR.Admin.WebApi.Controllers.mes.wm
+{
+
+ [Route("mes/wm/mr")]
+ public class MaterialRequisitionController : BaseController
+ {
+ private readonly IMaterialRequisitionService mquire;
+
+ public MaterialRequisitionController(IMaterialRequisitionService mquire)
+ {
+ this.mquire = mquire;
+ }
+
+
+
+ ///
+ /// 查询领料单
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("getmaterialsRequisition")]
+ public IActionResult GetmaterialsRequisition(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
+ {
+
+ (List, int) data = mquire.GetmaterialsRequisition(pageNum, pageSize, year, week, date);
+
+ return ToResponse(new ApiResult(200, "success", data));
+ }
+
+ }
+
+}
diff --git a/ZR.Model/MES/wm/WmMaterialrequisition.cs b/ZR.Model/MES/wm/WmMaterialrequisition.cs
new file mode 100644
index 00000000..0bfa646e
--- /dev/null
+++ b/ZR.Model/MES/wm/WmMaterialrequisition.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.Model.MES.wm
+{
+ ///
+ /// 领料单
+ ///
+ [SugarTable("wm_materialrequisition")]
+ public class WmMaterialrequisition
+ {
+ ///
+ /// 流水号
+ ///
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 毛坯零件号
+ ///
+ [SugarColumn(ColumnName = "workblankpartnumber")]
+ public string Workblankpartnumber { get; set; }
+
+
+ ///
+ /// 需要数量
+ ///
+ [SugarColumn(ColumnName = "requirenum")]
+ public int? Requirenum { get; set; }
+
+
+ ///
+ /// 状态 (0:未领料 1已经领料)
+ ///
+ [SugarColumn(ColumnName = "status")]
+ public string Status { get; set; }
+
+ ///
+ /// 年
+ ///
+ [SugarColumn(ColumnName = "year")]
+ public int? Year { get; set; }
+ ///
+ /// 周
+ ///
+ [SugarColumn(ColumnName = "week")]
+ public int? Week { get; set; }
+ ///
+ /// 日
+ ///
+ [SugarColumn(ColumnName = "date")]
+ public int? Date { get; set; }
+ ///
+ /// 乐观锁
+ ///
+ [SugarColumn(ColumnName = "REVISION")]
+ public int? Revision { 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.Model/MES/wm/WmWorkorderMr.cs b/ZR.Model/MES/wm/WmWorkorderMr.cs
new file mode 100644
index 00000000..84702d9e
--- /dev/null
+++ b/ZR.Model/MES/wm/WmWorkorderMr.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.Model.MES.wm
+{
+ ///
+ /// 生产工单与领料单关联表
+ ///
+ [SugarTable("wm_workorder_mr")]
+ public class WmWorkorderMr
+ {
+ ///
+ /// 流水号
+ ///
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 工单id
+ ///
+ [SugarColumn(ColumnName = "workorder_id")]
+ public string WorkorderId { get; set; }
+ ///
+ /// 领料单id
+ ///
+ [SugarColumn(ColumnName = "materialRequisition_id")]
+ public string MaterialrequisitionId { get; set; }
+ ///
+ /// 乐观锁
+ ///
+ [SugarColumn(ColumnName = "REVISION")]
+ public int? Revision { 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.Model/mes/pro/ProWorkorder.cs b/ZR.Model/mes/pro/ProWorkorder.cs
index 2aa0ff2d..e1a99f05 100644
--- a/ZR.Model/mes/pro/ProWorkorder.cs
+++ b/ZR.Model/mes/pro/ProWorkorder.cs
@@ -73,6 +73,15 @@ namespace ZR.Model.mes.pro
///
[SugarColumn(ColumnName = "production_time")]
public decimal? ProductionTime { get; set; }
+
+ ///
+ /// 零件号
+ ///
+ [SugarColumn(ColumnName = "partnumber")]
+ public string Partnumber { get; set; }
+
+
+
///
/// 产品名称
///
diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs
index 9b0f559a..552939c8 100644
--- a/ZR.Repository/BaseRepository.cs
+++ b/ZR.Repository/BaseRepository.cs
@@ -131,7 +131,7 @@ namespace ZR.Repository
}
///
- ///
+ /// 使用事务
///
///
/// 增删改查方法
diff --git a/ZR.Service/mes/pro/IService/IProWorkorderService.cs b/ZR.Service/mes/pro/IService/IProWorkorderService.cs
index d0bde9c0..f5b1b8e4 100644
--- a/ZR.Service/mes/pro/IService/IProWorkorderService.cs
+++ b/ZR.Service/mes/pro/IService/IProWorkorderService.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.AspNetCore.Http;
+using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -19,7 +20,7 @@ namespace ZR.Service.mes.pro.IService
public int SortWorkorderSchedule(string id, int sort);
- public int ReleaseProduction(string id);
+ public int ReleaseProduction(string id, HttpContext httpContext);
}
}
diff --git a/ZR.Service/mes/pro/ProWorkorderService.cs b/ZR.Service/mes/pro/ProWorkorderService.cs
index 4640788a..f40736c0 100644
--- a/ZR.Service/mes/pro/ProWorkorderService.cs
+++ b/ZR.Service/mes/pro/ProWorkorderService.cs
@@ -1,17 +1,24 @@
using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZR.Common;
using ZR.Model.mes.md;
using ZR.Model.mes.pro;
+using ZR.Model.MES.wm;
using ZR.Service.mes.pro.IService;
using ZR.Service.MES.md.IService;
+using static System.Net.WebRequestMethods;
+
+using JinianNet.JNTemplate;
+using static Aliyun.OSS.Model.LiveChannelStat;
namespace ZR.Service.mes.pro
{
@@ -26,12 +33,12 @@ namespace ZR.Service.mes.pro
.AndIF(year > 0, it => it.Year == year)
.AndIF(week > 0, it => it.Week == week)
.AndIF(date > 0, it => it.Date == date)
- .AndIF(isSchedule==0,it => it.Wrokerorder_status.Equals(isSchedule))
- .AndIF(isSchedule>=1,it => it.Wrokerorder_status>=1)
+ .AndIF(isSchedule == 0, it => it.Wrokerorder_status.Equals(isSchedule))
+ .AndIF(isSchedule >= 1, it => it.Wrokerorder_status >= 1)
.ToExpression();
int totalCount = 0;
- List proWorkorderList = Context.Queryable().Where(predicate).OrderBy(it=>it.Order).ToPageList(pageNum, pageSize, ref totalCount);
+ List proWorkorderList = Context.Queryable().Where(predicate).OrderBy(it => it.Order).ToPageList(pageNum, pageSize, ref totalCount);
return (proWorkorderList, totalCount);
}
@@ -39,22 +46,22 @@ namespace ZR.Service.mes.pro
public int SetWorkorderSechedule(string id, DateTime arrange_starttime, DateTime arrange_endtime)
{
//获取排序最大值
- if(CacheHelper.GetCache("workorder_id_max")==null)
+ if (CacheHelper.GetCache("workorder_id_max") == null)
{
- int? workorder_id_max = Context.Queryable().OrderBy(it => it.Order, OrderByType.Desc).First().Order;
+ int? workorder_id_max = Context.Queryable().OrderBy(it => it.Order, OrderByType.Desc).First().Order;
//初次
- if(workorder_id_max==null|| workorder_id_max==0)
+ if (workorder_id_max == null || workorder_id_max == 0)
{
workorder_id_max = 1;
}
CacheHelper.SetCache("workorder_id_max", workorder_id_max);
}
- CacheHelper.SetCache("workorder_id_max", (int)CacheHelper.GetCache("workorder_id_max")+1);
+ CacheHelper.SetCache("workorder_id_max", (int)CacheHelper.GetCache("workorder_id_max") + 1);
TimeSpan productionTime = arrange_endtime - arrange_starttime;
return Context.Updateable()
- .SetColumns(it => new ProWorkorder() { ArrangeStarttime = arrange_starttime, ArrangeEndtime = arrange_endtime, Wrokerorder_status = 1, ProductionTime = (decimal)productionTime.TotalMinutes,Order=(int) CacheHelper.GetCache("workorder_id_max") })
+ .SetColumns(it => new ProWorkorder() { ArrangeStarttime = arrange_starttime, ArrangeEndtime = arrange_endtime, Wrokerorder_status = 1, ProductionTime = (decimal)productionTime.TotalMinutes, Order = (int)CacheHelper.GetCache("workorder_id_max") })
.Where(it => it.Id.Equals(id))
.ExecuteCommand();
}
@@ -76,12 +83,72 @@ namespace ZR.Service.mes.pro
.ExecuteCommand();
}
- public int ReleaseProduction(string id)
+ public int ReleaseProduction(string id, HttpContext context)
{
- return Context.Updateable()
- .SetColumns(it => it.Wrokerorder_status == 2)
- .Where(it => it.Id.Equals(id))
- .ExecuteCommand();
+ int result = Context.Updateable()
+ .SetColumns(it => it.Wrokerorder_status == 2)
+ .Where(it => it.Id.Equals(id))
+ .ExecuteCommand();
+ ProWorkorder workorder = Context.Queryable().Where(it => it.Id == id).First();
+ if (result == 1)
+ {
+
+ // 生成领料单
+ // 若没有此零件号的领料单,就新增,否则,修改累加
+
+
+ bool isExit = Context.Queryable().Where(it => it.WorkorderId == workorder.Id).Any();
+ if (!isExit)
+ {
+ // 新增 领料单
+ WmMaterialrequisition materialrequisition = new WmMaterialrequisition();
+ materialrequisition.CreatedBy = context.User?.Identity?.Name;
+ materialrequisition.CreatedTime = DateTime.Now;
+ materialrequisition.Year = workorder.Year;
+ materialrequisition.Week = workorder.Week;
+ materialrequisition.Date = workorder.Date;
+ materialrequisition.Id = DateTime.Now.ToString("yyyyMMddHHmmss");
+ materialrequisition.Requirenum = workorder.Actualnumber;
+ materialrequisition.Workblankpartnumber = workorder.Workblankpartnumber;
+ materialrequisition.Status = "0";
+ Context.Insertable(materialrequisition).ExecuteCommandAsync();
+ // 新增工单-领料关联表
+ WmWorkorderMr mr = new WmWorkorderMr();
+ mr.Id = DateTime.Now.ToString("yyyyMMddHHmmss");
+ mr.WorkorderId = workorder.Id;
+ mr.MaterialrequisitionId = materialrequisition.Id;
+ mr.CreatedBy = context.User?.Identity?.Name;
+ mr.CreatedTime = DateTime.Now;
+ Context.Insertable(mr).ExecuteCommandAsync();
+ }
+ else
+ {
+ UseTran(() =>
+ {
+ //查询当前工单下的领料数量
+ List wm = Context.Queryable()
+ .LeftJoin((m, mr) => m.Id == mr.WorkorderId)
+ .LeftJoin((m, mr, r) => mr.MaterialrequisitionId == r.Id)
+ .Where(m => m.Id == id)
+ .Select((m, mr, r) => r)
+ .ToList();
+
+ wm[0].Requirenum += workorder.Actualnumber;
+ wm[0].UpdatedTime = DateTime.Now;
+ wm[0].UpdatedBy = context.User?.Identity?.Name;
+ //更新领料单
+ Context.Updateable(wm[0]);
+
+ });
+
+
+ }
+
+
+
+ }
+
+ return result;
}
}
}
diff --git a/ZR.Service/mes/wm/IService/IMaterialRequisitionService.cs b/ZR.Service/mes/wm/IService/IMaterialRequisitionService.cs
new file mode 100644
index 00000000..61ac07ef
--- /dev/null
+++ b/ZR.Service/mes/wm/IService/IMaterialRequisitionService.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZR.Model.MES.wm;
+
+namespace ZR.Service.mes.wm.IService
+{
+ public interface IMaterialRequisitionService
+ {
+
+ public (List, int) GetmaterialsRequisition(int pageNum, int pageSize, int year , int week , int date );
+ }
+}
diff --git a/ZR.Service/mes/wm/MaterialRequisitionService.cs b/ZR.Service/mes/wm/MaterialRequisitionService.cs
new file mode 100644
index 00000000..9f369c2b
--- /dev/null
+++ b/ZR.Service/mes/wm/MaterialRequisitionService.cs
@@ -0,0 +1,44 @@
+using Infrastructure.Attribute;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZR.Model.mes.pro;
+using ZR.Model.MES.qu;
+using ZR.Model.MES.wm;
+using ZR.Service.mes.qu.IService;
+using ZR.Service.mes.wm.IService;
+
+namespace ZR.Service.mes.wm
+{
+
+
+ [AppService(ServiceType = typeof(IMaterialRequisitionService), ServiceLifetime = LifeTime.Transient)]
+ public class MaterialRequisitionService : BaseService, IMaterialRequisitionService
+ {
+ public MaterialRequisitionService() {
+
+ }
+
+ public (List, int) GetmaterialsRequisition(int pageNum, int pageSize, int year, int week, int date)
+ {
+ var predicate = Expressionable.Create()
+ .AndIF(year > 0, it => it.Year == year)
+ .AndIF(week > 0, it => it.Week == week)
+ .AndIF(date > 0, it => it.Date == date)
+ .And(it=>it.Status=="0")
+ .ToExpression();
+
+ int totalCount = 0;
+ List wmmr = Context.Queryable().Where(predicate).OrderBy(it => it.Id).ToPageList(pageNum, pageSize, ref totalCount);
+
+ return (wmmr, totalCount);
+ }
+ }
+
+
+
+}