工单完成
This commit is contained in:
@@ -93,19 +93,47 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
//读取列表数据
|
||||
try
|
||||
{
|
||||
var list = stream.Query<ProWorkorder_v2>(sheetName: "Sheet1", startCell: "A3")
|
||||
.Where(it => it.FinishedPartNumber != null)
|
||||
.Where(it =>it.BlankNumber!=null&&!it.BlankNumber.Contains("圈数"))
|
||||
.ToList();
|
||||
list.ForEach(it =>
|
||||
{
|
||||
it.ToCreate(HttpContext);
|
||||
it.Year = year;
|
||||
it.Week = week;
|
||||
it.Date = date;
|
||||
var list = stream.Query<ProWorkorder_v2>(sheetName: "Sheet1", startCell: "A3").ToList(); ;
|
||||
|
||||
});
|
||||
string result = proWorkorderService.ImportExceldata(list);
|
||||
|
||||
foreach (ProWorkorder_v2 item in list)
|
||||
{
|
||||
if (item.BlankNumber == null)
|
||||
item.BlankNumber = "";
|
||||
if (item.FinishedPartNumber == null)
|
||||
item.FinishedPartNumber = "";
|
||||
if (item.ProductDescription == null)
|
||||
item.ProductDescription = "";
|
||||
if (item.Colour == null)
|
||||
item.Colour = "";
|
||||
if (item.FinishedPartNumber == null)
|
||||
item.FinishedPartNumber = "";
|
||||
if (item.ProductDescription == null)
|
||||
item.ProductDescription = "";
|
||||
if (item.Colour == null)
|
||||
item.Colour = "";
|
||||
if (item.Specifications == null)
|
||||
item.Specifications = "";
|
||||
if (item.CylinderNumber == null)
|
||||
item.CylinderNumber = "";
|
||||
if (item.Remark1 == null)
|
||||
item.Remark1 = "";
|
||||
if (item.Remark2 == null)
|
||||
item.Remark2 = "";
|
||||
if (item.Remark3 == null)
|
||||
item.Remark3 = "";
|
||||
if (item.Remark4 == null)
|
||||
item.Remark4 = "";
|
||||
if (item.ClientWorkorder == null)
|
||||
item.ClientWorkorder = "";
|
||||
item.ToCreate(HttpContext);
|
||||
item.Year = year;
|
||||
item.Week = week;
|
||||
item.Date = date;
|
||||
}
|
||||
var final_list = list.Where(it => !it.BlankNumber.Contains("圈数")).ToList();
|
||||
|
||||
string result = proWorkorderService.ImportExceldata(final_list);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -124,13 +152,13 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
/// <returns></returns>
|
||||
[HttpGet("downloadWorkorder")]
|
||||
[Log(Title = "下载生产工单", BusinessType = BusinessType.EXPORT)]
|
||||
public IActionResult UserExport(int? year, int? week,int? date)
|
||||
public IActionResult UserExport(int? year, int? week, int? date)
|
||||
{
|
||||
if (year == null || week == null || date==null)
|
||||
if (year == null || week == null || date == null)
|
||||
{
|
||||
return SUCCESS(0);
|
||||
}
|
||||
var result = proWorkorderService.ExportExceldata((int)year, (int)week,(int)date);
|
||||
var result = proWorkorderService.ExportExceldata((int)year, (int)week, (int)date);
|
||||
|
||||
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
@@ -147,7 +175,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
if (week != null && week > 0)
|
||||
{
|
||||
if (year != null && year > 0)
|
||||
data = proWorkorderService.DeleteAllWorkorder((int)year, (int)week,(int)date);
|
||||
data = proWorkorderService.DeleteAllWorkorder((int)year, (int)week, (int)date);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
@@ -212,6 +240,74 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除本周所有计划
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("updateSort")]
|
||||
public IActionResult UpdateSort(string id, int? sort)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
|
||||
data = proWorkorderService.UpdateworkorderSort(id, (int)sort);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单开始上线
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("startOnline/{id}")]
|
||||
public IActionResult StartOnline(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
data = proWorkorderService.StartWorkOrder(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单下线
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("cancelOnline/{id}")]
|
||||
public IActionResult CancelOnline(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
data = proWorkorderService.CancelWorkOrder(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成工单号
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("generateWorkorder")]
|
||||
public IActionResult GenerateWorkorder(int? year, int? week, int? date)
|
||||
{
|
||||
int data = 0;
|
||||
data = proWorkorderService.GenerateWorkorder((int)year, (int)week,(int)date);
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
[AllowAnonymous] //不需要授权 就可以访问
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
(string, string) result = DownloadImportTemplate("周生产计划模板");//返回文件名和路径
|
||||
(string, string) result = DownloadImportTemplate("周计划标准模板");//返回文件名和路径
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.VisualBasic;
|
||||
using Model.DBModel;
|
||||
using System;
|
||||
@@ -34,8 +35,14 @@ namespace ZR.Service.mes.pro.IService
|
||||
|
||||
public int UpdateWorkOrder(ProWorkorder_v2 workorder);
|
||||
|
||||
public int UpdateworkorderSort(string id ,int sort);
|
||||
|
||||
|
||||
public int StartWorkOrder(string id);
|
||||
public int CancelWorkOrder(string id);
|
||||
|
||||
public int GenerateWorkorder(int year, int week, int date);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +255,7 @@ namespace ZR.Service.mes.pro
|
||||
}
|
||||
|
||||
public int DeleteWorkOrder(string id)
|
||||
|
||||
{
|
||||
return Context.Deleteable<ProWorkorder_v2>().In(id).ExecuteCommand();
|
||||
|
||||
@@ -262,7 +263,99 @@ namespace ZR.Service.mes.pro
|
||||
|
||||
public int UpdateWorkOrder(ProWorkorder_v2 workorder)
|
||||
{
|
||||
workorder.Status = 0;
|
||||
if (workorder.Remark2 == "批量")
|
||||
{
|
||||
workorder.Remark3 = "是";
|
||||
}
|
||||
return Context.Updateable(workorder).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改工单顺序
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="sort"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int UpdateworkorderSort(string id, int sort)
|
||||
{
|
||||
if(sort > 0)
|
||||
{
|
||||
int finalreuslt = 0;
|
||||
|
||||
int max = Convert.ToInt32(sort.ToString().Substring(0, 6) + "999");
|
||||
int result = Context.Updateable<ProWorkorder_v2>().Where(it => it.Sort >= sort && it.Sort <= max).SetColumns(it => it.Sort == it.Sort + 1).ExecuteCommand();
|
||||
if (result > 0)
|
||||
{
|
||||
finalreuslt = Context.Updateable<ProWorkorder_v2>().Where(it => it.Id == id).SetColumns(it => it.Sort == sort).ExecuteCommand();
|
||||
}
|
||||
return finalreuslt;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单开始
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int StartWorkOrder(string id)
|
||||
{
|
||||
return Context.Updateable<ProWorkorder_v2>().Where(it => it.Id == id)
|
||||
.SetColumns(it => it.Status == 1).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单上线取消
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int CancelWorkOrder(string id)
|
||||
{
|
||||
|
||||
return Context.Updateable<ProWorkorder_v2>().Where(it => it.Id == id)
|
||||
.SetColumns(it => it.Status == 0).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成工单号
|
||||
/// </summary>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public int GenerateWorkorder(int year, int week, int date)
|
||||
{
|
||||
if (year > 0 && week > 0 && date >0)
|
||||
{
|
||||
string date_now = DateTime.Now.ToString("yyMMdd");
|
||||
|
||||
List<ProWorkorder_v2> workorderList= Context.Queryable<ProWorkorder_v2>().Where(it => it.Year == year && it.Week == week && it.Date == date).Where(it=>it.Remark3=="是").ToList();
|
||||
|
||||
foreach(ProWorkorder_v2 item in workorderList) {
|
||||
int index = workorderList.IndexOf(item) + 1;
|
||||
item.ClientWorkorder = date_now + index.ToString("000");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Context.Updateable(workorderList).ExecuteCommand();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user