Merge branch 'master' of https://gitee.com/doan-tech/zhuangpei-mesbackend
This commit is contained in:
commit
e5d669f2de
@ -27,7 +27,7 @@ namespace DOAN.Model.MES.product
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_station_id")]
|
||||
[SugarColumn(IsNullable=true,IsIdentity = false, ColumnName = "fk_station_id")]
|
||||
public int FkStationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -81,21 +81,21 @@ namespace DOAN.Service.MES.product
|
||||
/// <param name="WorkorderId">工单号(不是工单id) </param>
|
||||
/// <param name="WorkRouteID">工序id</param>
|
||||
/// <returns>工序绑定的工位列表</returns>
|
||||
public List<BaseWorkStationDto3> GetworkStation(string WorkorderId, int WorkProcessID)
|
||||
public List<BaseWorkStationDto3> GetworkStation(string WorkorderId, int WorkProcessID)
|
||||
{
|
||||
// 获取工序下可以选择的工位
|
||||
List<BaseWorkStationDto3> Choices= Context.Queryable<BaseWorkStation>()
|
||||
List<BaseWorkStationDto3> Choices = Context.Queryable<BaseWorkStation>()
|
||||
.Where(it => it.FkWorkProcesses == WorkProcessID)
|
||||
.ToList().Adapt<List<BaseWorkStationDto3>>();
|
||||
int Selected_id= Context.Queryable<ProRelWorkorderLineBody>()
|
||||
.Where(it => it.FkWorkorderId == WorkorderId)
|
||||
.Where(it => it.FkProcessId == WorkProcessID)
|
||||
.Select(it => it.FkStationId)
|
||||
.First();
|
||||
int Selected_id = Context.Queryable<ProRelWorkorderLineBody>()
|
||||
.Where(it => it.FkWorkorderId == WorkorderId)
|
||||
.Where(it => it.FkProcessId == WorkProcessID)
|
||||
.Select(it => it.FkStationId)
|
||||
.First();
|
||||
|
||||
if(Choices != null&& Choices.Count()>0)
|
||||
if (Choices != null && Choices.Count() > 0)
|
||||
{
|
||||
foreach(BaseWorkStationDto3 choice in Choices)
|
||||
foreach (BaseWorkStationDto3 choice in Choices)
|
||||
{
|
||||
if (choice.Id == Selected_id)
|
||||
{
|
||||
@ -123,11 +123,22 @@ namespace DOAN.Service.MES.product
|
||||
/// <returns></returns>
|
||||
public int UpdateSelectedWorkstation(ProRelWorkorderLineBodyDto lineBodyDto)
|
||||
{
|
||||
return Context.Updateable<ProRelWorkorderLineBody>()
|
||||
.SetColumns(it => it.FkStationId == lineBodyDto.FkStationId)
|
||||
|
||||
|
||||
int result = Context.Updateable<ProRelWorkorderLineBody>()
|
||||
.SetColumns(it => new ProRelWorkorderLineBody() { FkStationId = lineBodyDto.FkStationId })
|
||||
.Where(it => it.FkWorkorderId == lineBodyDto.FkWorkorderId)
|
||||
.Where(it => it.FkProcessId == lineBodyDto.FkProcessId).ExecuteCommand();
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
ProRelWorkorderLineBody lineBody = new ProRelWorkorderLineBody();
|
||||
lineBody.FkStationId = lineBodyDto.FkStationId;
|
||||
lineBody.FkWorkorderId = lineBodyDto.FkWorkorderId;
|
||||
lineBody.FkProcessId = lineBodyDto.FkProcessId;
|
||||
result = Context.Insertable(lineBody).ExecuteCommand();
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,30 +150,30 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
int result = 0;
|
||||
// 查询工单下单 工艺路线BaseRelWorkRouteProcesses
|
||||
string RouteCode = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == WorkorderId).Select(it => it.RouteId).First();
|
||||
var query= Context.Queryable<BaseWorkRoute>().Where(it => it.Code == RouteCode);
|
||||
int[] Processes_id= Context.Queryable(query).InnerJoin<BaseRelWorkRouteProcesses>((q, r) => q.Id == r.FkWorkRoute)
|
||||
string RouteCode = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == WorkorderId).Select(it => it.RouteId).First();
|
||||
var query = Context.Queryable<BaseWorkRoute>().Where(it => it.Code == RouteCode);
|
||||
int[] Processes_id = Context.Queryable(query).InnerJoin<BaseRelWorkRouteProcesses>((q, r) => q.Id == r.FkWorkRoute)
|
||||
.Select((q, r) => r.FkWorkProcesses).ToArray();
|
||||
var linqs = Context.Queryable<BaseWorkStation>();
|
||||
List<ProRelWorkorderLineBody> inserts= new List<ProRelWorkorderLineBody>();
|
||||
List<ProRelWorkorderLineBody> inserts = new List<ProRelWorkorderLineBody>();
|
||||
foreach (var process in Processes_id)
|
||||
{
|
||||
int station= linqs
|
||||
.Where(it => it.FkWorkProcesses == process)
|
||||
.Select(it=>it.Id).First();
|
||||
int station = linqs
|
||||
.Where(it => it.FkWorkProcesses == process)
|
||||
.Select(it => it.Id).First();
|
||||
|
||||
ProRelWorkorderLineBody lineBody= new ProRelWorkorderLineBody();
|
||||
ProRelWorkorderLineBody lineBody = new ProRelWorkorderLineBody();
|
||||
lineBody.FkWorkorderId = WorkorderId;
|
||||
lineBody.FkProcessId = process;
|
||||
lineBody.FkStationId= station;
|
||||
lineBody.CreatedTime= DateTime.Now;
|
||||
lineBody.FkStationId = station;
|
||||
lineBody.CreatedTime = DateTime.Now;
|
||||
inserts.Add(lineBody);
|
||||
}
|
||||
|
||||
UseTran2(() =>
|
||||
{
|
||||
Context.Deleteable<ProRelWorkorderLineBody>().Where(it=>it.FkWorkorderId == WorkorderId);
|
||||
result=Context.Insertable(inserts).ExecuteCommand();
|
||||
Context.Deleteable<ProRelWorkorderLineBody>().Where(it => it.FkWorkorderId == WorkorderId);
|
||||
result = Context.Insertable(inserts).ExecuteCommand();
|
||||
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user