生产领料完成
This commit is contained in:
parent
639a8988f5
commit
ce2e23ca02
@ -5,6 +5,7 @@ using ZR.Model.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对当前的,排产工单排序
|
||||
/// </summary>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询领料单
|
||||
/// </summary>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getmaterialsRequisition")]
|
||||
public IActionResult GetmaterialsRequisition(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
|
||||
(List<WmMaterialrequisition>, int) data = mquire.GetmaterialsRequisition(pageNum, pageSize, year, week, date);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
81
ZR.Model/MES/wm/WmMaterialrequisition.cs
Normal file
81
ZR.Model/MES/wm/WmMaterialrequisition.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 领料单
|
||||
///</summary>
|
||||
[SugarTable("wm_materialrequisition")]
|
||||
public class WmMaterialrequisition
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// 毛坯零件号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "workblankpartnumber")]
|
||||
public string Workblankpartnumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 需要数量
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "requirenum")]
|
||||
public int? Requirenum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态 (0:未领料 1已经领料)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "status")]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "year")]
|
||||
public int? Year { get; set; }
|
||||
/// <summary>
|
||||
/// 周
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "week")]
|
||||
public int? Week { get; set; }
|
||||
/// <summary>
|
||||
/// 日
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "date")]
|
||||
public int? Date { get; set; }
|
||||
/// <summary>
|
||||
/// 乐观锁
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "REVISION")]
|
||||
public int? Revision { 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; }
|
||||
}
|
||||
}
|
||||
56
ZR.Model/MES/wm/WmWorkorderMr.cs
Normal file
56
ZR.Model/MES/wm/WmWorkorderMr.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产工单与领料单关联表
|
||||
///</summary>
|
||||
[SugarTable("wm_workorder_mr")]
|
||||
public class WmWorkorderMr
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// 工单id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "workorder_id")]
|
||||
public string WorkorderId { get; set; }
|
||||
/// <summary>
|
||||
/// 领料单id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "materialRequisition_id")]
|
||||
public string MaterialrequisitionId { get; set; }
|
||||
/// <summary>
|
||||
/// 乐观锁
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "REVISION")]
|
||||
public int? Revision { 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; }
|
||||
}
|
||||
}
|
||||
@ -73,6 +73,15 @@ namespace ZR.Model.mes.pro
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "production_time")]
|
||||
public decimal? ProductionTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 零件号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "partnumber")]
|
||||
public string Partnumber { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
///</summary>
|
||||
|
||||
@ -131,7 +131,7 @@ namespace ZR.Repository
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 使用事务
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="action">增删改查方法</param>
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<ProWorkorder> proWorkorderList = Context.Queryable<ProWorkorder>().Where(predicate).OrderBy(it=>it.Order).ToPageList(pageNum, pageSize, ref totalCount);
|
||||
List<ProWorkorder> proWorkorderList = Context.Queryable<ProWorkorder>().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<ProWorkorder>().OrderBy(it => it.Order, OrderByType.Desc).First().Order;
|
||||
int? workorder_id_max = Context.Queryable<ProWorkorder>().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<ProWorkorder>()
|
||||
.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<ProWorkorder>()
|
||||
.SetColumns(it => it.Wrokerorder_status == 2)
|
||||
.Where(it => it.Id.Equals(id))
|
||||
.ExecuteCommand();
|
||||
int result = Context.Updateable<ProWorkorder>()
|
||||
.SetColumns(it => it.Wrokerorder_status == 2)
|
||||
.Where(it => it.Id.Equals(id))
|
||||
.ExecuteCommand();
|
||||
ProWorkorder workorder = Context.Queryable<ProWorkorder>().Where(it => it.Id == id).First();
|
||||
if (result == 1)
|
||||
{
|
||||
|
||||
// 生成领料单
|
||||
// 若没有此零件号的领料单,就新增,否则,修改累加
|
||||
|
||||
|
||||
bool isExit = Context.Queryable<WmWorkorderMr>().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<WmMaterialrequisition> wm = Context.Queryable<ProWorkorder>()
|
||||
.LeftJoin<WmWorkorderMr>((m, mr) => m.Id == mr.WorkorderId)
|
||||
.LeftJoin<WmMaterialrequisition>((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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
ZR.Service/mes/wm/IService/IMaterialRequisitionService.cs
Normal file
15
ZR.Service/mes/wm/IService/IMaterialRequisitionService.cs
Normal file
@ -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<WmMaterialrequisition>, int) GetmaterialsRequisition(int pageNum, int pageSize, int year , int week , int date );
|
||||
}
|
||||
}
|
||||
44
ZR.Service/mes/wm/MaterialRequisitionService.cs
Normal file
44
ZR.Service/mes/wm/MaterialRequisitionService.cs
Normal file
@ -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<QuRough>, IMaterialRequisitionService
|
||||
{
|
||||
public MaterialRequisitionService() {
|
||||
|
||||
}
|
||||
|
||||
public (List<WmMaterialrequisition>, int) GetmaterialsRequisition(int pageNum, int pageSize, int year, int week, int date)
|
||||
{
|
||||
var predicate = Expressionable.Create<WmMaterialrequisition>()
|
||||
.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<WmMaterialrequisition> wmmr = Context.Queryable<WmMaterialrequisition>().Where(predicate).OrderBy(it => it.Id).ToPageList(pageNum, pageSize, ref totalCount);
|
||||
|
||||
return (wmmr, totalCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user