Commit 675758a1 by jiawei.su
parents ce5a4872 ba1c7d76
......@@ -37,7 +37,7 @@
>
<Option
v-for="(item, index) in productList"
:value="item.id"
:value="item.code"
:key="index"
:label="
item.name +
......@@ -75,7 +75,7 @@
clearable
filterable
class="searchSelect"
v-model="state"
v-model="status"
>
<Option :value="1">待执行</Option>
<Option :value="2">执行中</Option>
......@@ -296,7 +296,7 @@ export default {
productList: [],
taskNumber: "",
sn: "",
state: 0,
status: 0,
performType: 0,
startTime: [],
endTime: [],
......@@ -326,6 +326,7 @@ export default {
complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: page,
pageSize: pagesize,
TaskNo: this.taskNumber,
};
this.axios
.request({
......@@ -399,20 +400,6 @@ export default {
}
);
},
exportExcel() {
// this.axios.request({
// url: "/config/Download/GetTemplate?name=StorageLocation",
// method: "get",
// })
// .then((res) => {
// if (res.data.ret === 1) {
// window.location.href =
// this.axios.publicPath + "" + res.data.data;
// } else {
// this.$Message.error(this.$t(res.data.msg));
// }
// });
},
initlevel() {
// 初始化产线层级
this.axios
......@@ -454,17 +441,33 @@ export default {
this.endTime = val;
},
exportExcel() {
let data = {};
let params = {
section: this.sectionid,
tasktype: this.taskType,
productCode: this.productCode,
sn: this.sn,
status: this.status,
actionType: this.performType,
triggerbegin:
this.startTime.length > 0 ? this.startTime[0] : "",
triggerend: this.startTime.length > 0 ? this.startTime[1] : "",
complatebegin: this.endTime.length > 0 ? this.endTime[0] : "",
complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: this.page,
pageSize: this.pagesize,
TaskNo: this.taskNumber,
toexcel: '1'
};
this.axios
.request({
url: "",
data,
method: "",
url: "/acc/AutomationState/GetTasklist",
params,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
window.location.href =
axios.publicPath + "" + res.data.data;
this.axios.publicPath + "" + res.data.data;
} else {
this.$Message.error(this.$t(res.data.msg));
}
......
......@@ -12,6 +12,11 @@ using Siger.Middlelayer.Common;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Log;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities;
using System.IO;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Siger.ApiACC.Controllers
......@@ -95,17 +100,79 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(output);
}
[HttpGet]
public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggerbegin,string triggerend, string complatebegin,string complatend,int page,int pageSize)
public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggerbegin,string triggerend, string complatebegin,string complatend,int page,int pageSize, string toexcel)
{
var ids = new List<int>();
if (section != 0)
{
ids = _sigerProjectLevelSection.GetLevelSectionIds(section, ProjectId).ToList();
}
var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggerbegin, triggerend, complatebegin, complatend, ProjectId,page,pageSize);
var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggerbegin, triggerend, complatebegin, complatend, ProjectId,page,pageSize,toexcel);
if(toexcel.ToInt() == 1)
{
return ExportExcel(resulst.Data);
}
return new PagedObjectResult(resulst, resulst.Total, page, pageSize);
}
public IActionResult ExportExcel(IEnumerable<ResponseAutomationTasklist> data)
{
var rootDir = FileSystemHelper.GetPhysicalFolders(FileSystemHelper.CommonFileSetting.PhysicalFolder, FileSystemHelper.ExportFileName);
if (!data.Any())
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataList = new List<AutomationStateList>();
foreach (var item in data)
{
var model = Mapper<ResponseAutomationTasklist, AutomationStateList>.Map(item);
switch (item.status)
{
case 1:
model.status_value = "待执行";
break;
case 2:
model.status_value = "执行中";
break;
case 3:
model.status_value = "执行完成";
break;
case 4:
model.status_value = "取消";
break;
default:
model.status_value = "";
break;
}
dataList.Add(model);
}
if (dataList.Any())
{
EpPlusExcelHelper<AutomationStateList> helper = null;
try
{
helper = new EpPlusExcelHelper<AutomationStateList>();
var temporaryFileName = $"任务清单管理_AutomationTaskData_{DateTime.Now:yyyyMMddHHmmss}.xlsx";
helper.GenerateExcel(dataList, Path.Combine(rootDir, temporaryFileName));
return new ObjectResult($"{FileSystemHelper.CommonFileSetting.RequestPath}/{FileSystemHelper.ExportFileName}/{temporaryFileName}");
}
catch (Exception e)
{
Logger.WriteLineError("Export Fixture Automation Task Data failed, error:" + e);
throw new BadRequestException(RequestEnum.ExportFailed);
}
finally
{
helper?.Dispose();
}
}
throw new BadRequestException(CommonEnum.Fail);
}
public IActionResult DeleteTask(int id)
{
var record = _automationTaskList.Get(f => f.id == id);
......
......@@ -71,11 +71,6 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ProductNotFound);
}
var route = _beatSetRepository.Get(q => q.projectID == ProjectId && q.status == (int)RowState.Valid && q.id == req.routeid.ToInt());
if (route == null)
{
throw new BadRequestException(RequestEnum.ProcessNotFind);
}
if (string.IsNullOrEmpty(req.sn))
{
throw new BadRequestException(RequestEnum.PleaseInputPartSerialNumber);
......
......@@ -15,11 +15,13 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 手动任务
/// </summary>
Manual=1,
[Description("手动任务")]
Manual =1,
/// <summary>
/// 自动任务
/// </summary>
Auto=2
[Description("自动任务")]
Auto =2
}
/// <summary>
/// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行
......@@ -29,14 +31,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 未执行
/// </summary>
[Description("未执行")]
None=0,
/// <summary>
/// 手动执行
/// </summary>
[Description("手动执行")]
Manual = 1,
/// <summary>
/// 自动执行
/// </summary>
[Description("自动执行")]
Auto = 2
}
/// <summary>
......@@ -71,14 +76,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 待生产
/// </summary>
[Description("待生产")]
Waiting = 1,
/// <summary>
/// 生产中
/// </summary>
[Description("生产中")]
Produce = 2,
/// <summary>
/// 生产完成
/// </summary>
[Description("生产完成")]
Complated = 3
}
......
......@@ -249,4 +249,45 @@ namespace Siger.Middlelayer.Utility.ImportEntities
[ExcelColumn("维护时间")]
public string UpdateTime { get; set; }
}
public class AutomationStateList : ImportBase
{
[ExcelColumn("任务编号")]
public string taskno { get; set; }
[ExcelColumn("产线层级")]
public string section { get; set; }
[ExcelColumn("触发方")]
public string trigger { get; set; }
[ExcelColumn("任务类型")]
public string tasktype { get; set; }
[ExcelColumn("工件编号")]
public string sn { get; set; }
[ExcelColumn("工单编号")]
public string ordernumber { get; set; }
[ExcelColumn("产品编号")]
public string productCode { get; set; }
[ExcelColumn("工序编号")]
public string routeNo { get; set; }
[ExcelColumn("工序名称")]
public string route { get; set; }
[ExcelColumn("程序号")]
public string program { get; set; }
[ExcelColumn("储位位置")]
public string location { get; set; }
[ExcelColumn("工装编号")]
public string fixtureCode { get; set; }
[ExcelColumn("动作")]
public string action { get; set; }
[ExcelColumn("执行类型")]
public string actionType { get; set; }
[ExcelColumn("状态")]
public string status_value { get; set; }
[ExcelColumn("触发时间")]
public string triggerTime { get; set; }
[ExcelColumn("完成时间")]
public string complatetime { get; set; }
}
}
......@@ -89,7 +89,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
}
public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin, string triend, string compbegin, string compend, int projectid, int page, int pagesize)
public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin, string triend, string compbegin, string compend, int projectid, int page, int pagesize, string toexcel)
{
var query = from q in _context.siger_automation_task_list
join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid
......@@ -121,8 +121,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
route=r!=null?$"{r.serialNumber}-{r.name}":"",
send=q.send,
tasktype=EnumHelper.GetEnumDesc(q.tasktype),
tasktypeid = Convert.ToInt32(q.tasktype),
status=q.status,
actionTypeid = Convert.ToInt32(q.actiontype)
};
Expression<Func<ResponseAutomationTasklist, bool>> sectonsExpression = f => true;
if (sections.Any())
......@@ -165,14 +167,26 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
comptimeExpression = q => q.complatevalue >= compbegin.ToDateTime() && q.complatevalue <= compend.ToDateTime();
}
Expression<Func<ResponseAutomationTasklist, bool>> statusExpression = f => true;
if (status != 0)
{
statusExpression = q => q.status == status;
}
var expression = sectonsExpression.And(taskTypeExpression).And(productCodeExpression).And(tasknoExpression).And(snExpression)
.And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression);
.And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression).And(statusExpression);
var entities = query.Where(expression).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(expression).Count();
return new PagedCollectionResult<ResponseAutomationTasklist>(entities, totalCount);
if (toexcel.ToInt() == 1)
{
var entities = query.Where(expression).AsNoTracking().ToList();
return new PagedCollectionResult<ResponseAutomationTasklist>(entities, entities.Count);
}
else
{
var entities = query.Where(expression).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(expression).Count();
return new PagedCollectionResult<ResponseAutomationTasklist>(entities, totalCount);
}
}
}
}
......@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
string CreateRandonSn(string productCode);
IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin,string triend,string compbegin, string compend, int projectid, int page, int pagesize);
IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin,string triend,string compbegin, string compend, int projectid, int page, int pagesize, string toexcel);
}
}
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