油漆
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
using Infrastructure.Extensions;
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.mes.md;
|
||||
using ZR.Model.mes.pro;
|
||||
using ZR.Model.MES.pro.DTO;
|
||||
using ZR.Service.mes.pro;
|
||||
using ZR.Service.mes.pro.IService;
|
||||
using ZR.Service.MES.md;
|
||||
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.MES.pro
|
||||
{
|
||||
|
||||
[Route("mes/pro/workorder")]
|
||||
public class ProWorkorderController : BaseController
|
||||
{
|
||||
private readonly IProWorkorderService proWorkorderService;
|
||||
|
||||
public ProWorkorderController(IProWorkorderService proWorkorderService)
|
||||
{
|
||||
this.proWorkorderService = proWorkorderService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有非排产工单
|
||||
/// </summary>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getworkorderListwithoutschedule")]
|
||||
public IActionResult GetWorkorderListWithoutSchedule(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
(List<ProWorkorder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 甘特图
|
||||
/// </summary>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("GetGanttList")]
|
||||
public IActionResult GetGanttList(int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
GanttTaskDTO data = proWorkorderService.GetGanttList(year, week, date);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有排产工单
|
||||
/// </summary>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getworkorderListwithschedule")]
|
||||
public IActionResult GetWorkorderListWithSchedule(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
(List<ProWorkorder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 1);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据工单ID,设置为排产状态
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <param name="arrange_starttime">预计开始时间</param>
|
||||
/// <param name="arrange_endtime">预计结束时间</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("setschedule")]
|
||||
public IActionResult SetSchedule(string id, DateTime arrange_starttime, DateTime arrange_endtime)
|
||||
{
|
||||
|
||||
|
||||
int data = proWorkorderService.SetWorkorderSechedule(id, arrange_starttime, arrange_endtime);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据工单ID,设置为非排产状态
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("resetschedule/{id}")]
|
||||
public IActionResult ResetSchedule(string id)
|
||||
{
|
||||
|
||||
int data = proWorkorderService.ResetWorkorderSechedule(id);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下达开始领料指令
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("releaseProduction/{id}")]
|
||||
public IActionResult ReleaseProduction(string id)
|
||||
{
|
||||
|
||||
int data = proWorkorderService.ReleaseProduction(id, HttpContext);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对当前的,排产工单排序
|
||||
/// </summary>
|
||||
/// <param name="parameter">列表参数,一个是工单ID,一个是排序号</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("sortschedule")]
|
||||
public IActionResult SortSchedule([FromBody] List<ProWorkorderSortDTO> parameter)
|
||||
{
|
||||
int sum = 0;
|
||||
foreach (ProWorkorderSortDTO item in parameter)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(item.id))
|
||||
{
|
||||
int data = proWorkorderService.SortWorkorderSchedule(item.id, item.order);
|
||||
sum += data;
|
||||
}
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", sum));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
using Infrastructure.Extensions;
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MiniExcelLibs;
|
||||
using Model.DBModel;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using System.Text.Json;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
|
||||
using ZR.Model.MES.pro;
|
||||
using ZR.Model.MES.pro.DTO;
|
||||
using ZR.Service.mes.pro;
|
||||
using ZR.Service.mes.pro.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
{
|
||||
[Route("mes/pro/workorder_v2")]
|
||||
public class ProWorkorderV2Controller : BaseController
|
||||
{
|
||||
|
||||
|
||||
private readonly IProWorkorderServiceV2 proWorkorderService;
|
||||
|
||||
|
||||
|
||||
public ProWorkorderV2Controller(IProWorkorderServiceV2 proWorkorderService)
|
||||
{
|
||||
this.proWorkorderService = proWorkorderService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpGet("getWorkoderList")]
|
||||
public IActionResult GetWorkorderList(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
(List<ProWorkOrder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpGet("getWorkoderList_piliang")]
|
||||
public IActionResult GetWorkorderList_Piliang(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
(List<ProWorkorder_v2>, int) data = proWorkorderService.GetWorkorderList_Piliang(pageNum, pageSize, year, week, date, 0);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产工单模板下载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "生产工单模板模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||||
[AllowAnonymous] //不需要授权 就可以访问
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
(string, string) result = DownloadImportTemplate("日生产计划模板");//返回文件名和路径
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "生产计划导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||
{
|
||||
//1.0 读取excel 文件 保存在指定位置
|
||||
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
|
||||
string sFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + formFile.FileName;
|
||||
string target = Path.Combine(webHostEnvironment.WebRootPath, "workorder", sFileName);
|
||||
int year = 0;
|
||||
int week = 0;
|
||||
int date = 0;
|
||||
if (!Directory.Exists(Path.Combine(webHostEnvironment.WebRootPath, "workorder")))
|
||||
{
|
||||
// 如果目录不存在就创建
|
||||
Directory.CreateDirectory(Path.Combine(webHostEnvironment.WebRootPath, "workorder"));
|
||||
|
||||
}
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
FileStream targetFileStream = new FileStream(target, FileMode.Create, FileAccess.Write);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
targetFileStream.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
|
||||
//读取列表数据
|
||||
try
|
||||
{
|
||||
//2.0 解析excel
|
||||
//读取第一行 解析 年和月
|
||||
var row = stream.Query().Skip(1).First();
|
||||
year = Convert.ToInt32(row.A);
|
||||
week = Convert.ToInt32(row.B);
|
||||
date = Convert.ToInt32(row.C);
|
||||
var list = stream.Query<ProWorkorder_v2>(sheetName: "Sheet1", startCell: "A3").ToList(); ;
|
||||
|
||||
|
||||
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.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("圈数"))
|
||||
.Where(it => !(it.BlankNumber == "" && it.FinishedPartNumber == "" && it.ProductDescription == "" && it.Specifications == "" && it.CylinderNumber == "" && it.Remark1 == "" && it.Remark2== "" && it.Remark3 == "" && it.Remark4== ""&&it.ClientWorkorder==""))
|
||||
.ToList();
|
||||
|
||||
string result = proWorkorderService.ImportExceldata(final_list);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ToResponse(ResultCode.GLOBAL_ERROR, "内容错误,请仔细检测格式,并联系管理员" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器下载 生产工单
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("downloadWorkorder")]
|
||||
[Log(Title = "下载生产工单", BusinessType = BusinessType.EXPORT)]
|
||||
public IActionResult UserExport(int? year, int? week, int? date)
|
||||
{
|
||||
if (year == null || week == null || date == null)
|
||||
{
|
||||
return SUCCESS(0);
|
||||
}
|
||||
var result = proWorkorderService.ExportExceldata((int)year, (int)week, (int)date);
|
||||
|
||||
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除本周所有计划
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteAll")]
|
||||
public IActionResult DeleteAllItem(int? year, int? week, int? date)
|
||||
{
|
||||
int data = 0;
|
||||
if (week != null && week > 0)
|
||||
{
|
||||
if (year != null && year > 0)
|
||||
data = proWorkorderService.DeleteAllWorkorder((int)year, (int)week, (int)date);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增生产工单
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产工单对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addworkorder")]
|
||||
public IActionResult AddWorkOrder([FromBody] ProWorkorder_v2 proWorkorder)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkorder != null)
|
||||
{
|
||||
proWorkorder.ToCreate(HttpContext);
|
||||
data = proWorkorderService.AddWorkOrder(proWorkorder);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除生产工单
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteitem/{id}")]
|
||||
public IActionResult DeleteItem(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
data = proWorkorderService.DeleteWorkOrder(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新生产计划
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("updateworkorder")]
|
||||
public IActionResult UpdateWorkOrder([FromBody] ProWorkorder_v2 proWorkorder)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkorder != null)
|
||||
{
|
||||
proWorkorder.ToUpdate(HttpContext);
|
||||
data = proWorkorderService.UpdateWorkOrder(proWorkorder);
|
||||
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <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="oldId">初始序号</param>
|
||||
/// <param name="oldSort">初始排序</param>
|
||||
/// <param name="newId">放入序号</param>
|
||||
/// <param name="newSort">放入排序</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("updateSort2")]
|
||||
public IActionResult UpdateSort2(string oldId, int oldSort, string newId, int newSort)
|
||||
{
|
||||
int result = 0;
|
||||
if (string.IsNullOrEmpty(oldId)&& string.IsNullOrEmpty(newId))
|
||||
{
|
||||
return ToResponse(new ApiResult(400, "updateSortError", "排序参数异常"));
|
||||
}
|
||||
result = proWorkorderService.UpdateworkorderSort2(oldId, oldSort, newId, newSort);
|
||||
return ToResponse(new ApiResult(200, "success", result));
|
||||
}
|
||||
|
||||
|
||||
/// <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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Model.mes.md;
|
||||
using ZR.Model.mes.pro;
|
||||
using ZR.Service.mes.pro.IService;
|
||||
using ZR.Service.MES.md;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.MES.pro
|
||||
{
|
||||
|
||||
[Route("mes/pro/workplan")]
|
||||
public class ProWorkplanController : BaseController
|
||||
{
|
||||
private readonly IProWorkplanService proWorkplanService;
|
||||
|
||||
public ProWorkplanController(IProWorkplanService proWorkplanService)
|
||||
{
|
||||
this.proWorkplanService = proWorkplanService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取生产计划列表
|
||||
/// </summary>
|
||||
/// <param name="pageNum">页编号</param>
|
||||
/// <param name="pageSize">页大小</param>
|
||||
/// <param name="year">年份</param>
|
||||
/// <param name="week">周数</param>
|
||||
/// <param name="partNumber">零件号</param>
|
||||
/// <param name="color">颜色</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public IActionResult List(int pageNum, int pageSize, int year=-1, int week=-1, string partNumber = "", string color = "")
|
||||
{
|
||||
(List<ProWorkplan>,int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增生产计划
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addworkplan")]
|
||||
public IActionResult AddWorkPlan([FromBody] ProWorkplan proWorkplan)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkplan!=null)
|
||||
{
|
||||
proWorkplan.ToCreate(HttpContext);
|
||||
data = proWorkplanService.AddWorkPlan(proWorkplan);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新生产计划
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("updateworkplan")]
|
||||
public IActionResult UpdateWorkPlan([FromBody] ProWorkplan proWorkplan)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkplan != null)
|
||||
{
|
||||
proWorkplan.ToUpdate(HttpContext);
|
||||
data = proWorkplanService.UpdateWorkPlan(proWorkplan);
|
||||
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除生产计划
|
||||
/// </summary>
|
||||
/// <param name="id">计划ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteitem/{id}")]
|
||||
public IActionResult DeleteItem(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
data = proWorkplanService.DeleteWorkPlan(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取生产工单
|
||||
/// </summary>
|
||||
/// <param name="id">计划ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getworkorderList/{id}")]
|
||||
public IActionResult GetWorkorderList(string id)
|
||||
{
|
||||
List<ProWorkorder> lst = new List<ProWorkorder>();
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
lst = proWorkplanService.GetWorkorderListByPlanId(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", lst));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增生产工单
|
||||
/// </summary>
|
||||
/// <param name="proWorkorder">生产工单对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addworkorder")]
|
||||
public IActionResult AddWorkorder([FromBody] ProWorkorder proWorkorder)
|
||||
{
|
||||
// TODO 获取工单对象
|
||||
// TODO 增加插入时间,插入人员:ToCreate
|
||||
// TODO 根据工单对象里的计划ID,查询生产计划的数量,判断工单数和要小于等于计划数:能插入,正常返回,0或1;大于,2
|
||||
|
||||
int data = 0;
|
||||
if (proWorkorder != null)
|
||||
{
|
||||
proWorkorder.Id = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
string workPlanId = proWorkorder.FkProPlanId;
|
||||
string workorderId = proWorkorder.Id;
|
||||
|
||||
if (!string.IsNullOrEmpty(workPlanId) && !string.IsNullOrEmpty(workorderId))
|
||||
{
|
||||
// 查询生产计划对象
|
||||
List<ProWorkplan> lstWorkplan = proWorkplanService.GetProWorkplanById(workPlanId);
|
||||
|
||||
// 查询所有生产工单
|
||||
List<ProWorkorder> lstWorkorder = proWorkplanService.GetWorkorderListByPlanId(workPlanId);
|
||||
|
||||
// 计算所有工单的数量和,生产计划的数量:比较
|
||||
if(lstWorkplan!=null && lstWorkplan.Count==1)
|
||||
{
|
||||
int countWorkplan = int.Parse(lstWorkplan[0].ActualplanNumber.Trim());
|
||||
|
||||
// 计算已有工单的计划数
|
||||
int countWorkorder = 0;
|
||||
foreach (ProWorkorder item in lstWorkorder)
|
||||
{
|
||||
countWorkorder += item.Actualnumber.GetValueOrDefault();
|
||||
}
|
||||
|
||||
// 再加上当前订单计划数
|
||||
countWorkorder += proWorkorder.Actualnumber.GetValueOrDefault();
|
||||
|
||||
// 计划数>0 计划数要大于等于当前工单总数
|
||||
if(countWorkplan > 0 && (countWorkplan>= countWorkorder))
|
||||
{
|
||||
proWorkorder.Partnumber = lstWorkplan[0].Partnumber;
|
||||
proWorkorder.ToCreate(HttpContext);
|
||||
data = proWorkplanService.AddWorkorder(proWorkorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新生产工单
|
||||
/// </summary>
|
||||
/// <param name="proWorkorder">生产工单对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("updateworkorder")]
|
||||
public IActionResult UpdateWorkorder([FromBody] ProWorkorder proWorkorder)
|
||||
{
|
||||
// TODO 判断更新的数量是否超过计划数
|
||||
|
||||
int data = 0;
|
||||
if (proWorkorder != null) // 工单对象不为空
|
||||
{
|
||||
string workPlanId = proWorkorder.FkProPlanId;
|
||||
string workorderId = proWorkorder.Id;
|
||||
|
||||
// 判断计划ID,工单ID要非空
|
||||
if (!string.IsNullOrEmpty(workPlanId) && !string.IsNullOrEmpty(workorderId))
|
||||
{
|
||||
string isArrange = "0";
|
||||
|
||||
// 查询所有生产工单,根据生产计划ID
|
||||
List<ProWorkorder> lstWorkorder = proWorkplanService.GetWorkorderListByPlanId(workPlanId);
|
||||
|
||||
// 找到要更新的工单,要判断当前工单状态
|
||||
ProWorkorder currentWorkorder = null;
|
||||
foreach (ProWorkorder item in lstWorkorder)
|
||||
{
|
||||
if(item.Id.Equals(workorderId)) // 找到当前工单ID的对象
|
||||
{
|
||||
//if(!string.IsNullOrEmpty(item.Wrokerorder_status)) isArrange = item.Isarrange;
|
||||
isArrange = item.Wrokerorder_status.ToString();
|
||||
currentWorkorder = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 状态为未排产状态,才能更新
|
||||
if ("0".Equals(isArrange))
|
||||
{
|
||||
// 查询生产计划对象
|
||||
List<ProWorkplan> lstWorkplan = proWorkplanService.GetProWorkplanById(workPlanId);
|
||||
|
||||
// 计算所有工单的数量和,生产计划的数量:比较
|
||||
if (lstWorkplan != null && lstWorkplan.Count == 1)
|
||||
{
|
||||
int countWorkplan = int.Parse(lstWorkplan[0].ActualplanNumber.Trim()); // 计划数
|
||||
|
||||
// 当前所有工单总数
|
||||
int countWorkorder = 0;
|
||||
foreach (ProWorkorder item in lstWorkorder)
|
||||
{
|
||||
countWorkorder += item.Actualnumber.GetValueOrDefault();
|
||||
}
|
||||
if(currentWorkorder!=null) countWorkorder -= currentWorkorder.Actualnumber.GetValueOrDefault(); // 减去当前工单的数值
|
||||
|
||||
// 再加上要更新的值
|
||||
countWorkorder += proWorkorder.Actualnumber.GetValueOrDefault();
|
||||
|
||||
// 计划数>0 计划数要大于等于当前工单总数
|
||||
if (countWorkplan > 0 && (countWorkplan >= countWorkorder))
|
||||
{
|
||||
proWorkorder.ToUpdate(HttpContext);
|
||||
data = proWorkplanService.UpdateWorkorder(proWorkorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else data = 3;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除生产工单
|
||||
/// </summary>
|
||||
/// <param name="id">工单ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteworkorder/{id}")]
|
||||
public IActionResult DeleteWorkorder(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
// 查询所有生产工单,根据生产计划ID
|
||||
List<ProWorkorder> lstWorkorder = proWorkplanService.GetWorkorderListById(id);
|
||||
|
||||
// 查询工单非空,数量必须为1个
|
||||
if (lstWorkorder != null && lstWorkorder.Count == 1)
|
||||
{
|
||||
string isArrange = "0";
|
||||
|
||||
// 排产状态非空
|
||||
isArrange = lstWorkorder[0].Wrokerorder_status.ToString();
|
||||
|
||||
// 排产状态为 0 ,可执行删除
|
||||
if ("0".Equals(isArrange))
|
||||
{
|
||||
data = proWorkplanService.DeleteWorkorder(id);
|
||||
}
|
||||
else data = 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
using Aliyun.OSS;
|
||||
using AutoMapper.Configuration.Conventions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting.Internal;
|
||||
using MimeKit;
|
||||
using MiniExcelLibs;
|
||||
using MiniExcelLibs.OpenXml;
|
||||
using Model.DBModel;
|
||||
using Org.BouncyCastle.Crypto.IO;
|
||||
using System.IO;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
using ZR.Model.mes.pro;
|
||||
using ZR.Model.MES.pro.DTO;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.mes.pro;
|
||||
using ZR.Service.mes.pro.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.mes.pro
|
||||
{
|
||||
[Route("mes/pro/workplan_v2")]
|
||||
public class ProWorkplanV2Controller : BaseController
|
||||
{
|
||||
|
||||
private readonly IProWorkplanServiceV2 proWorkplanService;
|
||||
|
||||
public ProWorkplanV2Controller(IProWorkplanServiceV2 proWorkplanService)
|
||||
{
|
||||
this.proWorkplanService = proWorkplanService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取生产计划列表
|
||||
/// </summary>
|
||||
/// <param name="pageNum">页编号</param>
|
||||
/// <param name="pageSize">页大小</param>
|
||||
/// <param name="year">年份</param>
|
||||
/// <param name="week">周数</param>
|
||||
/// <param name="partNumber">零件号</param>
|
||||
/// <param name="color">颜色</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public IActionResult List(int pageNum, int pageSize, int year = -1, int week = -1, string partNumber = "", string color = "")
|
||||
{
|
||||
(List<ProWorklplanDto>, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color);
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增生产计划
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addworkplan")]
|
||||
public IActionResult AddWorkPlan([FromBody] ProWorklplan_v2 proWorkplan)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkplan != null)
|
||||
{
|
||||
proWorkplan.ToCreate(HttpContext);
|
||||
data = proWorkplanService.AddWorkPlan(proWorkplan);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除生产计划
|
||||
/// </summary>
|
||||
/// <param name="id">计划ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteitem/{id}")]
|
||||
public IActionResult DeleteItem(string id)
|
||||
{
|
||||
int data = 0;
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
data = proWorkplanService.DeleteWorkPlan(id);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除本周所有计划
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteAll")]
|
||||
public IActionResult DeleteAllItem(int? year,int? week)
|
||||
{
|
||||
int data = 0;
|
||||
if (week!=null&&week>0)
|
||||
{
|
||||
if (year != null && year > 0)
|
||||
data = proWorkplanService.DeleteAllWorkPlan((int)year,(int)week);
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新生产计划
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("updateworkplan")]
|
||||
public IActionResult UpdateWorkPlan([FromBody] ProWorklplan_v2 proWorkplan)
|
||||
{
|
||||
int data = 0;
|
||||
if (proWorkplan != null)
|
||||
{
|
||||
proWorkplan.ToUpdate(HttpContext);
|
||||
data = proWorkplanService.UpdateWorkPlan(proWorkplan);
|
||||
|
||||
}
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生产计划模板下载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "生产计划模板模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||||
[AllowAnonymous] //不需要授权 就可以访问
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
(string, string) result = DownloadImportTemplate("周计划标准模板");//返回文件名和路径
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取周汇总
|
||||
/// </summary>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getWeekSummary")]
|
||||
public IActionResult GetWeekSummary(int? year, int? week)
|
||||
{
|
||||
if (year == null && week == null)
|
||||
{
|
||||
return SUCCESS(0);
|
||||
}
|
||||
WorkplanSummaryDto workplanSummaryDto = proWorkplanService.GetWeekSummary((int)year, (int)week);
|
||||
return SUCCESS(workplanSummaryDto);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "生产计划导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||
{
|
||||
//1.0 读取excel 文件 保存在指定位置
|
||||
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
|
||||
string sFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + formFile.FileName;
|
||||
string target = Path.Combine(webHostEnvironment.WebRootPath, "workplan", sFileName);
|
||||
if (!Directory.Exists(Path.Combine(webHostEnvironment.WebRootPath, "workplan")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(webHostEnvironment.WebRootPath, "workplan"));
|
||||
}
|
||||
int year = 0;
|
||||
int week = 0;
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
FileStream targetFileStream = new FileStream(target, FileMode.Create, FileAccess.Write);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
targetFileStream.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//读取列表数据
|
||||
try
|
||||
{
|
||||
//2.0 解析excel
|
||||
//读取第一行 解析 年和月
|
||||
var row = stream.Query().Take(1).First();
|
||||
year = Convert.ToInt32(row.A);
|
||||
week = Convert.ToInt32(row.B);
|
||||
var list = stream.Query<ProWorklplan_v2>(sheetName: "Sheet1", startCell: "B3")
|
||||
.Where(it => it.Partnumber != null)
|
||||
.Where(it => !it.Partnumber.Contains("合计"))
|
||||
.Where(it => it.RequireNum > 0)
|
||||
.ToList();
|
||||
list.ForEach(it =>
|
||||
{
|
||||
it.ToCreate(HttpContext);
|
||||
it.Year = year;
|
||||
it.Week = week;
|
||||
it.NoSchedule = it.RequireNum;
|
||||
|
||||
});
|
||||
string result = proWorkplanService.ImportExceldata(list);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ToResponse(ResultCode.GLOBAL_ERROR,"内容错误,请仔细检测格式,并联系管理员"+ex.Message);
|
||||
}
|
||||
}
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器下载 生产计划
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("downloadWorkplan")]
|
||||
[Log(Title = "下载生产计划", BusinessType = BusinessType.EXPORT)]
|
||||
public IActionResult UserExport(int? year, int? week)
|
||||
{
|
||||
if (year == null || week == null)
|
||||
{
|
||||
return SUCCESS(0);
|
||||
}
|
||||
var result = proWorkplanService.ExportExceldata((int)year, (int)week);
|
||||
|
||||
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产计划检查
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("checkWorkPlan")]
|
||||
public IActionResult CheckWorkPlan([FromBody] ProWorklplan_v2 proWorkplan)
|
||||
{
|
||||
try
|
||||
{
|
||||
int result = proWorkplanService.CheckWorkPlan(proWorkplan);
|
||||
return ToResponse(new ApiResult(200, "success", result));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ToResponse(new ApiResult(500, ex.Message, 0));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Service.mes.pro.IService;
|
||||
using ZR.Model.MES.pro.DTO;
|
||||
using ZR.Model.mes.pro;
|
||||
|
||||
//创建时间:2024-05-20
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 包装记录
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("mes/pro/WmPackingrecord")]
|
||||
public class WmPackingrecordController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 包装记录接口
|
||||
/// </summary>
|
||||
private readonly IWmPackingrecordService _WmPackingrecordService;
|
||||
|
||||
public WmPackingrecordController(IWmPackingrecordService WmPackingrecordService)
|
||||
{
|
||||
_WmPackingrecordService = WmPackingrecordService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询包装记录列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:list")]
|
||||
public IActionResult QueryWmPackingrecord([FromQuery] WmPackingrecordQueryDto parm)
|
||||
{
|
||||
var response = _WmPackingrecordService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询包装记录详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:query")]
|
||||
public IActionResult GetWmPackingrecord(long Id)
|
||||
{
|
||||
var response = _WmPackingrecordService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<WmPackingrecord>();
|
||||
return SUCCESS(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加包装记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:add")]
|
||||
[Log(Title = "包装记录", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddWmPackingrecord([FromBody] WmPackingrecordDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<WmPackingrecord>().ToCreate(HttpContext);
|
||||
|
||||
var response = _WmPackingrecordService.AddWmPackingrecord(modal);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新包装记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:edit")]
|
||||
[Log(Title = "包装记录", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateWmPackingrecord([FromBody] WmPackingrecordDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<WmPackingrecord>().ToUpdate(HttpContext);
|
||||
var response = _WmPackingrecordService.UpdateWmPackingrecord(modal);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除包装记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:delete")]
|
||||
[Log(Title = "包装记录", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteWmPackingrecord(string ids)
|
||||
{
|
||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _WmPackingrecordService.Delete(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user