生产领料完成
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user