Commit f5a860da by jiawei.su

someupdate

parent eee35f58
......@@ -43,3 +43,8 @@ Server/.vs/SigerData/v15/Server/sqlite3/storage.ide
*.targets
/Server/Schedule/Siger.Schedule.ToolsModule/obj/Debug/netstandard2.0/Siger.Schedule.ToolsModule.AssemblyInfo.cs
*.props
*.png
*.xml
*.svg
*.so
*.zip
......@@ -2077,6 +2077,8 @@ export default {
'3000164': '设备已经生产完成',
'3000165': '该设备当前无工装状态',
'3000166': '未配置字典信息',
'3000167': '产线当前为自动模式',
'3000168': '该任务已经下发',
'400000': '设备状态',
'400002': '更改状态',
......
......@@ -18,6 +18,9 @@ using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.Repository.Response;
using Siger.Middlelayer.Share.Constant;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using Siger.Middlelayer.Common.Configuration;
using Siger.Middlelayer.Common.Helpers;
using Newtonsoft.Json;
namespace Siger.ApiACC.Controllers
{
......@@ -190,8 +193,69 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(AccEnum.LineIsAutoMode);
}
//TODO
return new ObjectResult(1);
var host = GetHost();
if (string.IsNullOrEmpty(host))
{
throw new BadRequestException(CommonEnum.Fail);
}
var sendToPLC = new RequestPLC
{
RStation = taskobj.sectionid,
Fixture = taskobj.fixtureguid,
RequestForm = taskobj.no,
RobotStep = (int)taskobj.action,
StorageNo = taskobj.locationid,
SN = taskobj.sn,
Program = taskobj.programnumber
};
var result = PushTask(host, sendToPLC, out string message);
if (!result)
{
Logger.WriteLineError($"TASK 下发失败 : {message}");
throw new BadRequestException(CommonEnum.Fail);
}
taskobj.send = 1;
_automationTaskList.Update(taskobj);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
private bool PushTask(string ip, RequestPLC request, out string msg)
{
msg = string.Empty;
try
{
var param = JsonHelper.SerializerToJsonString(request);
var retstring = HttpHelper.HttpPost($"{ip}{CommonConst.SenTaskToMES}", "application/json", param);
var result = JsonConvert.DeserializeObject<ResponsePlC>(retstring);
if (result.return_code != 0)
{
msg = $"PushTask failed,URL{ip} input:{param } result :{result.return_desc}";
return false;
}
return true;
}
catch (Exception ex)
{
msg = ex.ToString();
}
return false;
}
private string GetHost()
{
var host = ConfigManager.GetValue("ProjectSetting", "Host", string.Empty);
if (string.IsNullOrEmpty(host))
{
Logger.WriteLineError("DbSetting about [ProjectSetting] Host not found.");
return null;
}
return host;
}
/// <summary>
/// 扫描
......
......@@ -29,10 +29,10 @@ namespace Siger.ApiACC.Tasks
}
using (DBhelper dbhelper = new DBhelper())
{
var linemode=
var tasklist = dbhelper.GetTaskList(projectId);
if (!tasklist.Any())
{
Logger.WriteLineInfo($"无任务下发");
return;
}
......
......@@ -25,16 +25,9 @@ namespace Siger.ApiACC.Tasks
ConfigDbContext = new ApiConfigDbContext();
}
internal bool CanTask(int projectId, int section)
public siger_automation_line_mode GetLineMode(int projectId)
{
var taskObj = AccDbContext.siger_automation_task_list.FirstOrDefault(f => f.projectId == projectId && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
if (taskObj == null)
return true;
else
return false;
return AccDbContext.siger_automation_line_mode.FirstOrDefault(f => f.projectId == projectId);
}
/// <summary>
/// 获取未推送tasklist
......@@ -43,9 +36,12 @@ namespace Siger.ApiACC.Tasks
/// <returns></returns>
public IEnumerable<siger_automation_task_list> GetTaskList(int projectId)
{
var taskObjs = AccDbContext.siger_automation_task_list.Where(f => f.projectId == projectId && f.send==0 && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
return taskObjs;
var query = from q in AccDbContext.siger_automation_task_list
join l in AccDbContext.siger_project_level_section on q.sectionid equals l.id
join lm in AccDbContext.siger_automation_line_mode on l.parentid equals lm.section
where q.projectId == projectId && lm.mode == 1 && q.send==0
select q;
return query;
}
public siger_automation_fixture_tools_monitor GetMonitor(int section)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment