using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
using SqlSugar;
|
using WIDESEA_ISerialPortRepository;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseRepository;
|
using WIDESEAWCS_Core.BaseServices;
|
using WIDESEAWCS_DTO.SerialPort;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
|
namespace WIDESEAWCS_TaskInfoService
|
{
|
public class ProcessServer : ServiceBase<Dt_Process, IProcessRepository>, IProcessServer
|
{
|
|
private IUnitOfWorkManage _unitOfWorkManage;
|
public ProcessServer(IProcessRepository BaseDal, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
|
{
|
_unitOfWorkManage=unitOfWorkManage;
|
}
|
|
|
|
public WebResponseContent GetProcess(string gruop)
|
{
|
try
|
{
|
_unitOfWorkManage.BeginTran();
|
var proce = BaseDal.QueryData(i => i.CraftType == gruop);
|
|
|
_unitOfWorkManage.CommitTran();
|
if (proce != null)
|
{
|
return new WebResponseContent { Status = true, Data = proce };
|
}
|
else
|
{
|
return new WebResponseContent{ Status = false, Message = "数据为空"};
|
}
|
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return new WebResponseContent { Status = false, Message = "失败" + ex.Message };
|
}
|
}
|
|
public WebResponseContent GetSleeveandStep(string gruops)
|
{
|
try
|
{
|
_unitOfWorkManage.BeginTran();
|
var result = BaseDal.QueryData(x => x.CraftType == gruops) // 先筛选 CraftType
|
.GroupBy(x => x.CraftType) // 按 CraftType 分组
|
.Select(g => new
|
{
|
maxNodal = g.Max(a=>a.Nodal),
|
sumTorqueSum = g.Sum(a=>a.TorqueSum)
|
}).ToList();
|
_unitOfWorkManage.CommitTran() ;
|
return new WebResponseContent { Status = true, Data = result };
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return new WebResponseContent { Status = false, Message = "查询失败:" + ex.Message };
|
}
|
}
|
|
|
public WebResponseContent AddProcess(AddProcessDTO addProcessDTO)
|
{
|
try
|
{
|
var proces = new Dt_Process();
|
proces.Nodal=addProcessDTO.nodal;
|
proces.CraftType=addProcessDTO.craftstype;
|
proces.CraftsStep=addProcessDTO.craftsstep;
|
proces.CraftContent=addProcessDTO.craftcontent;
|
proces.TorqueSum = addProcessDTO.sleeveNum;
|
proces.Tools=addProcessDTO.tools;
|
_unitOfWorkManage.BeginTran() ;
|
BaseDal.AddData(proces);
|
_unitOfWorkManage.CommitTran();
|
return new WebResponseContent { Status = true,Data=proces};
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran() ;
|
return new WebResponseContent { Status = false, Message = "查询失败:" + ex.Message };
|
}
|
}
|
|
public WebResponseContent Upprocess(PutProcessDTO addProcessDTO)
|
{
|
try
|
{
|
var proces = BaseDal.QueryData(x => x.CraftID == addProcessDTO.id).FirstOrDefault();
|
if (proces == null)
|
{
|
return new WebResponseContent { Status = false,Message="没有找到"};
|
}
|
proces.Nodal = addProcessDTO.nodal;
|
proces.CraftType = addProcessDTO.craftstype;
|
proces.CraftsStep = addProcessDTO.craftsstep;
|
proces.CraftContent = addProcessDTO.craftcontent;
|
proces.TorqueSum = addProcessDTO.sleeveNum;
|
proces.Tools = addProcessDTO.tools;
|
_unitOfWorkManage.BeginTran();
|
BaseDal.UpdateData(proces);
|
_unitOfWorkManage.CommitTran();
|
return new WebResponseContent { Status = true, Data = proces };
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return new WebResponseContent { Status = false, Message = "查询失败:" + ex.Message };
|
}
|
}
|
|
public WebResponseContent Getcircuit(string groups)
|
{
|
try
|
{
|
List<Dt_Process> results = new List<Dt_Process>();
|
int step = 1;
|
|
while (true)
|
{
|
// 查询当前步骤的数据
|
var circuit = BaseDal.QueryData(x => x.CraftType == groups && x.SetpNum == step)
|
.FirstOrDefault();
|
|
// 如果查询结果为空,则停止循环
|
if (circuit == null)
|
{
|
break;
|
}
|
|
// 加入结果列表
|
results.Add(circuit);
|
|
// 递增 step,继续查询下一个步骤
|
step++;
|
}
|
|
return new WebResponseContent { Status = true, Data = results };
|
}
|
catch (Exception ex)
|
{
|
return new WebResponseContent { Status = false, Message = "查询失败:" + ex.Message };
|
}
|
}
|
|
|
|
}
|
}
|