首检完成

This commit is contained in:
qianhao.xu
2024-01-26 16:59:00 +08:00
parent 9b024fb100
commit 641e9c198a
24 changed files with 359 additions and 52 deletions

View File

@@ -42,6 +42,17 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
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>
@@ -71,6 +82,12 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
int year = 0;
int week = 0;
int date = 0;
if (!Directory.Exists(target))
{
// 如果目录不存在就创建
Directory.CreateDirectory(target);
}
using (var stream = formFile.OpenReadStream())
{
FileStream targetFileStream = new FileStream(target, FileMode.Create, FileAccess.Write);
@@ -82,17 +99,18 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
targetFileStream.Write(buffer, 0, bytesRead);
}
//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);
//读取列表数据
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(); ;
@@ -106,12 +124,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
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)
@@ -131,14 +144,16 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
item.Week = week;
item.Date = date;
}
var final_list = list.Where(it => !it.BlankNumber.Contains("圈数")).ToList();
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 ToResponse(ResultCode.GLOBAL_ERROR, "内容错误,请仔细检测格式,并联系管理员" + ex.Message);
}
}
@@ -305,7 +320,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
public IActionResult GenerateWorkorder(int? year, int? week, int? date)
{
int data = 0;
data = proWorkorderService.GenerateWorkorder((int)year, (int)week,(int)date);
data = proWorkorderService.GenerateWorkorder((int)year, (int)week, (int)date);
return ToResponse(new ApiResult(200, "success", data));
}

View File

@@ -169,6 +169,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
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(target))
{
Directory.CreateDirectory(target);
}
int year = 0;
int week = 0;
using (var stream = formFile.OpenReadStream())
@@ -182,17 +186,18 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
targetFileStream.Write(buffer, 0, bytesRead);
}
//2.0 解析excel
//读取第一行 解析 年和月
var row = stream.Query().Take(1).First();
year = Convert.ToInt32(row.A);
week = Convert.ToInt32(row.B);
//读取列表数据
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("合计"))
@@ -203,6 +208,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
it.ToCreate(HttpContext);
it.Year = year;
it.Week = week;
it.NoSchedule = it.RequireNum;
});
string result = proWorkplanService.ImportExceldata(list);
@@ -210,7 +216,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
}
catch (Exception ex)
{
return ToResponse(ResultCode.GLOBAL_ERROR,"模板内容错误,请仔细检测格式,并联系管理员"+ex.Message);
return ToResponse(ResultCode.GLOBAL_ERROR,"内容错误,请仔细检测格式,并联系管理员"+ex.Message);
}
}
return SUCCESS(null);

View File

@@ -25,7 +25,8 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
private readonly IFirstFQCService fQCService;
private readonly IHubContext<MessageHub> hubContext;
public FirstFQCController(IFirstFQCService fQCService, IHubContext<MessageHub> hubContext) {
public FirstFQCController(IFirstFQCService fQCService, IHubContext<MessageHub> hubContext)
{
this.fQCService = fQCService;
this.hubContext = hubContext;
}
@@ -40,18 +41,62 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
public IActionResult GetcheckItemTable()
{
CheckItemTableDTO itemTableDTO= fQCService.GetCheckItemTable();
CheckItemTableDTO itemTableDTO = fQCService.GetCheckItemTable();
return SUCCESS(itemTableDTO);
}
[HttpGet("getcheckitemRecord")]
public IActionResult GetcheckitemRecord()
public IActionResult GetcheckitemRecord()
{
return null;
}
/// <summary>
/// 获取当前工单
/// </summary>
/// <returns></returns>
[HttpGet("getcurrentWorkorder")]
public IActionResult GetcurrentWorkorder()
{
QcCurrentWorkorderDto workorder= fQCService.GetcurrentWorkorder();
return SUCCESS(workorder);
}
/// <summary>
/// 获取下一个工单
/// </summary>
/// <returns></returns>
[HttpGet("getcurrentWorkorder_next")]
public IActionResult GetcurrentWorkorder_next()
{
QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_next();
return SUCCESS(workorder);
}
/// <summary>
/// 获取上一个工单
/// </summary>
/// <returns></returns>
[HttpGet("getcurrentWorkorder_previous")]
public IActionResult GetcurrentWorkorder_previous()
{
QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_previous();
return SUCCESS(workorder);
}
}
}

View File

@@ -44,8 +44,8 @@
<Folder Include="Images\" />
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="wwwroot\export\" />
<Folder Include="wwwroot\workplan\" />
<Folder Include="wwwroot\workorder\" />
<Folder Include="wwwroot\workplan\" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ZR.Model.MES.qc.DTO
{
/// <summary>
/// 当前工单
/// </summary>
public class QcCurrentWorkorderDto
{
/// <summary>
/// 工单号
/// </summary>
public string ClientWorkorder { set; get; }
/// <summary>
/// 产品描述
/// </summary>
public string ProductDescription { set; get; }
/// <summary>
/// 零件号
/// </summary>
public string FinishedPartNumber { set; get; }
/// <summary>
/// 规格
/// </summary>
public string Specifications { set; get; }
/// <summary>
///颜色
/// </summary>
public string Colour { set; get; }
/// <summary>
/// A/B班
/// </summary>
public string Team { set; get; }
/// <summary>
/// 投入数
/// </summary>
public int PreviousNumber { set; get; }
/// <summary>
/// 一次合格数
/// </summary>
public int FirstPassNumber { set; get; }
/// <summary>
/// 一次合格率
/// </summary>
public double FirstPassRate { set; get; }
/// <summary>
/// 打磨数
/// </summary>
public int PolisheNumber { set; get; }
/// <summary>
/// 报废数
/// </summary>
public int ScrapNumber { set; get; }
/// <summary>
/// 抛光数
/// </summary>
public int DefectNumber { set; get; }
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using SqlSugar;
namespace ZR.Model.MES.qc
{
@@ -14,7 +15,7 @@ namespace ZR.Model.MES.qc
/// 流水号
///</summary>
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; }
public string Id { get; set; }
/// <summary>
/// 工单id
///</summary>

View File

@@ -20,6 +20,8 @@ namespace ZR.Service.mes.pro.IService
public (List<ProWorkorder_v2>, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule);
public (List<ProWorkorder_v2>, int) GetWorkorderList_Piliang(int pageNum, int pageSize, int year, int week, int date, int isSchedule);
public string ImportExceldata(List<ProWorkorder_v2> proWorklplans);

View File

@@ -46,6 +46,21 @@ namespace ZR.Service.mes.pro
return (proWorkorderList, totalCount);
}
public (List<ProWorkorder_v2>, int) GetWorkorderList_Piliang(int pageNum, int pageSize, int year, int week, int date, int isSchedule)
{
var predicate = Expressionable.Create<ProWorkorder_v2>()
.AndIF(year > 0, it => it.Year == year)
.AndIF(week > 0, it => it.Week == week)
.AndIF(date > 0, it => it.Date == date)
.ToExpression();
int totalCount = 0;
List<ProWorkorder_v2> proWorkorderList = Context.Queryable<ProWorkorder_v2>().Where(predicate).Where(it=>it.Remark3=="是").OrderBy(it => it.Sort).ToPageList(pageNum, pageSize, ref totalCount);
return (proWorkorderList, totalCount);
}
/// <summary>
/// 获取生产计划id
/// </summary>
@@ -163,15 +178,8 @@ namespace ZR.Service.mes.pro
//2.0 保存为excel
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{year}年{week}周{date}日计划-{DateTime.Now:MM-dd-HHmmss}.xlsx";
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
var Sheet1 = new
{
year = year,
@@ -183,20 +191,9 @@ namespace ZR.Service.mes.pro
};
string templatePath = Path.Combine(webHostEnvironment.WebRootPath, "ImportTemplate", "日生产计划模板1.xlsx");
MiniExcel.SaveAsByTemplate(fullPath, templatePath, Sheet1);
// MiniExcel.SaveAs(fullPath, list);
//3.0 返回路径和文件名
return (sFileName, fullPath);
}
/// <summary>
@@ -209,6 +206,8 @@ namespace ZR.Service.mes.pro
{
return Context.Deleteable<ProWorkorder_v2>().Where(it => it.Year == year && it.Week == week && it.Date == date).ExecuteCommand();
}
/// <summary>
/// 获取生产计划id
/// </summary>
@@ -268,7 +267,8 @@ namespace ZR.Service.mes.pro
{
workorder.Remark3 = "是";
}
return Context.Updateable(workorder).ExecuteCommand();
return Context.Updateable(workorder).IgnoreColumns(it => new { it.CreatedBy, it.CreatedTime,it.Remark4,it.Sort }).ExecuteCommand();
}
/// <summary>

View File

@@ -5,9 +5,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.pro;
using ZR.Model.MES.qc;
using ZR.Model.MES.qc.DTO;
using ZR.Model.MES.qu;
@@ -48,7 +50,7 @@ namespace ZR.Service.mes.qc
{
//更新实时记录表
QcFirstinspectionRecord record = new QcFirstinspectionRecord();
record.Id = DateTime.Now.ToString("MMddHHmmss");
record.Id = DateTime.Now.ToString("YYMMddHHmmss");
record.InspectionModule = InspectionModule;
record.FKWorkorderId = workorder_id;
record.FKInpectionId = checkid.Substring(0, 3);
@@ -100,7 +102,7 @@ namespace ZR.Service.mes.qc
{
//更新实时记录表
QcAgaininspectionRecord record = new QcAgaininspectionRecord();
record.Id = DateTime.Now.ToString("MMddHHmmss");
record.Id = DateTime.Now.ToString("YYMMddHHmmss");
record.InspectionModule = InspectionModule;
record.FkWorkorderId = workorder_id;
record.FkInpectionId = checkid.Substring(0, 3);
@@ -150,7 +152,7 @@ namespace ZR.Service.mes.qc
{
//更新实时记录表
QcFinalinspectionRecord record = new QcFinalinspectionRecord();
record.Id = DateTime.Now.ToString("MMddHHmmss");
record.Id = DateTime.Now.ToString("YYMMddHHmmss");
record.InspectionModule = InspectionModule;
record.FkWorkorderId = workorder_id;
record.FkInpectionId = checkid.Substring(0, 3);
@@ -161,7 +163,7 @@ namespace ZR.Service.mes.qc
.ToStorage();
x.AsInsertable.ExecuteCommandAsync(); //执行插入
x.AsUpdateable.ExecuteCommandAsync(); //执行更新
x.AsUpdateable.UpdateColumns(it => new { it.UpdatedBy,it.UpdatedTime,it.Counter }).ExecuteCommandAsync(); //执行更新
////更新初检报废表
//if (Convert.ToInt32(checkid) / 10 % 10==3)
@@ -345,5 +347,167 @@ namespace ZR.Service.mes.qc
double percentage = ((double)num1 / num2) * 100;
return Math.Round(percentage, 2);
}
public static QcCurrentWorkorderDto Now_producting_Workorder = null; //当前生产工单
/// <summary>
/// 获取当前_生产中_工单列表
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public List<QcCurrentWorkorderDto> GetNow_producting_WorkorderList()
{
List<ProWorkorder_v2> workorders= Context.Queryable<ProWorkorder_v2>().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it=>it.Sort).ToList();
List<QcCurrentWorkorderDto> qcCurrentList= new List<QcCurrentWorkorderDto>();
foreach(ProWorkorder_v2 item in workorders)
{
qcCurrentList.Add(new QcCurrentWorkorderDto()
{
ClientWorkorder = item.ClientWorkorder,
ProductDescription = item.ProductDescription,
FinishedPartNumber = item.FinishedPartNumber,
Specifications = item.Specifications,
Colour = item.Colour,
Team = "",
PreviousNumber=item.PreviousNumber,
FirstPassNumber=0,
FirstPassRate=0.0,
PolisheNumber=0,
ScrapNumber = 0,
DefectNumber = 0
});
;
}
return qcCurrentList;
}
/// <summary>
/// 获取当前生产工单
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public QcCurrentWorkorderDto GetcurrentWorkorder()
{
//获取状态为1的生产工单列表
List<QcCurrentWorkorderDto> Now_producting_WorkorderList= GetNow_producting_WorkorderList();
// 当前没有生产工单
if (Now_producting_WorkorderList==null|| Now_producting_WorkorderList.Count<=0)
{
Now_producting_Workorder = null;
return null;
}
else if(Now_producting_Workorder==null)
{
Now_producting_Workorder = Now_producting_WorkorderList[0];
return Now_producting_Workorder;
}
else
{
return Now_producting_Workorder;
}
}
/// <summary>
/// 获取下一个生产工单
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public QcCurrentWorkorderDto GetcurrentWorkorder_next()
{
//获取状态为1的生产工单列表
List<QcCurrentWorkorderDto> Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
Now_producting_Workorder = null;
return null;
}
else
{
// 当前没有生产工单
if (Now_producting_Workorder == null)
{
return null;
}
//获取上一个工单号 游标
int index= Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder== Now_producting_Workorder.ClientWorkorder);
if (index < 0)
{
// 逻辑异常
Now_producting_Workorder = Now_producting_WorkorderList[0];
return null;
}
if (index== Now_producting_WorkorderList.Count()-1)
{
// 已经是最后一个了没有
return null;
}
else
{
Now_producting_Workorder = Now_producting_WorkorderList[index + 1];
return Now_producting_Workorder;
}
}
}
/// <summary>
/// 获取上一个工单
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public QcCurrentWorkorderDto GetcurrentWorkorder_previous()
{
//获取状态为1的生产工单列表
List<QcCurrentWorkorderDto> Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
Now_producting_Workorder = null;
return null;
}
else
{
// 当前没有生产工单
if (Now_producting_Workorder == null)
{
return null;
}
//获取上一个工单号 游标
int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder.ClientWorkorder);
if (index < 0)
{
// 逻辑异常
Now_producting_Workorder = Now_producting_WorkorderList[0];
return null;
}
if (index == 0)
{
// 已经是最后一个了没有
return null;
}
else
{
Now_producting_Workorder = Now_producting_WorkorderList[index -1];
return Now_producting_Workorder;
}
}
}
}
}

View File

@@ -13,5 +13,9 @@ namespace ZR.Service.mes.qc.IService
public Task SaveinspectItem_v1(string workorder_id, string InspectionModule, string checkid, int counter);
public Task SaveinspectItem_v2(string workorder_id, string InspectionModule, string checkid, int counter);
public Task SaveinspectItem_v3(string workorder_id, string InspectionModule, string checkid, int counter);
public QcCurrentWorkorderDto GetcurrentWorkorder();
public QcCurrentWorkorderDto GetcurrentWorkorder_next();
public QcCurrentWorkorderDto GetcurrentWorkorder_previous();
}
}