From 1ca03bd2a504f71094097476f3ef3195ba749704 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 28 Nov 2023 18:18:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BA=8E=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/mes/qc/QcRoughController.cs | 15 +++ .../mes/qc/QcinspectionItemController.cs | 36 +++++++ ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs | 7 -- ZR.Service/mes/pro/ProWorkorderService.cs | 18 +++- ZR.Service/mes/qc/IService/IQcRoughService.cs | 1 + ZR.Service/mes/qc/QcRoughService.cs | 96 ++++++++++++++----- 6 files changed, 142 insertions(+), 31 deletions(-) create mode 100644 ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs index 6518383c..4f891906 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/QcRoughController.cs @@ -11,6 +11,7 @@ using ZR.Model.MES.qc.DTO; using ZR.Service.mes.pro; using ZR.Service.mes.pro.IService; using ZR.Service.mes.qu.IService; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace ZR.Admin.WebApi.Controllers.mes.qu { @@ -40,5 +41,19 @@ namespace ZR.Admin.WebApi.Controllers.mes.qu return ToResponse(new ApiResult(200, "success", data)); } + /// + /// 更新统计表 + /// + /// + + [HttpGet("updateStatisticsTable")] + public IActionResult UpdateStatisticsTable(string id, int actualNumber, int randomRate, int ngs, int oks, decimal oksRatio,int Isqualified) + { + + if (string.IsNullOrEmpty(id)) + return ToResponse(new ApiResult(200, "success", 0)); + int result = quRoughService.UpdateStatisticsTable(id, actualNumber, randomRate, ngs, oks, oksRatio,Isqualified); + return ToResponse(new ApiResult(200, "success", result)); + } } } diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs new file mode 100644 index 00000000..ebc77b80 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs @@ -0,0 +1,36 @@ +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; + + +namespace ZR.Admin.WebApi.Controllers.mes.qc +{ + + + [Route("mes/qc/IQC")] + public class QcinspectionItemController : BaseController + { + readonly IQcinspectionItemService qcinspection; + + public QcinspectionItemController(IQcinspectionItemService qcinspection) + { + + this.qcinspection= qcinspection; + } + + + [HttpGet] + public ActionResult Get() + { + return qcinspection.Get(); + } + } + + + +} diff --git a/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs b/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs index ceb0edc6..c8569ddf 100644 --- a/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs +++ b/ZR.Model/MES/qc/DTO/Mr_QuRoughDTO.cs @@ -27,13 +27,6 @@ namespace ZR.Model.MES.qc.DTO public string Workblankpartnumber { get; set; } - /// - /// 需要数量 - /// - - public int? Requirenum { get; set; } - - /// /// 状态 (0:未领料 1已经领料) /// diff --git a/ZR.Service/mes/pro/ProWorkorderService.cs b/ZR.Service/mes/pro/ProWorkorderService.cs index 08284b8b..24358395 100644 --- a/ZR.Service/mes/pro/ProWorkorderService.cs +++ b/ZR.Service/mes/pro/ProWorkorderService.cs @@ -20,6 +20,7 @@ using static System.Net.WebRequestMethods; using JinianNet.JNTemplate; using static Aliyun.OSS.Model.LiveChannelStat; using ZR.Model.MES.pro.DTO; +using ZR.Model.MES.qu; namespace ZR.Service.mes.pro { @@ -97,7 +98,6 @@ namespace ZR.Service.mes.pro // 生成领料单 // 若没有此零件号的领料单,就新增,否则,修改累加 - bool isExit = Context.Queryable().Where(it => it.WorkorderId == workorder.Id).Any(); if (!isExit) { @@ -121,6 +121,17 @@ namespace ZR.Service.mes.pro mr.CreatedBy = context.User?.Identity?.Name; mr.CreatedTime = DateTime.Now; Context.Insertable(mr).ExecuteCommandAsync(); + + //新增领料单统计表 + QcRough qcRough=new QcRough (); + qcRough.Id = DateTime.Now.ToString("yyyyMMddHHmmss"); + qcRough.FkMaterialrequisitionId= materialrequisition.Id; + qcRough.RequireNum = materialrequisition.Requirenum; + qcRough.ActualNumber = materialrequisition.Requirenum; + qcRough.CreatedBy= context.User?.Identity?.Name; + qcRough.CreatedTime= DateTime.Now; + qcRough.OksRatio = 10; + Context.Insertable (qcRough).ExecuteCommandAsync(); } else { @@ -139,7 +150,10 @@ namespace ZR.Service.mes.pro wm[0].UpdatedBy = context.User?.Identity?.Name; //更新领料单 Context.Updateable(wm[0]); - + //更新检验表 + Context.Updateable().SetColumns(it => it.RequireNum == wm[0].Requirenum) + .SetColumns(it => it.ActualNumber == wm[0].Requirenum) + .Where(it => it.FkMaterialrequisitionId == wm[0].Id).ExecuteCommandAsync(); }); diff --git a/ZR.Service/mes/qc/IService/IQcRoughService.cs b/ZR.Service/mes/qc/IService/IQcRoughService.cs index 016ce262..76041bd7 100644 --- a/ZR.Service/mes/qc/IService/IQcRoughService.cs +++ b/ZR.Service/mes/qc/IService/IQcRoughService.cs @@ -13,5 +13,6 @@ namespace ZR.Service.mes.qu.IService public interface IQcRoughService { public (List, int) GetStatisticslist(int pageNum, int pageSize, int year, int week, int date, int isSchedule); + public int UpdateStatisticsTable(string id, int actualNumber, int randomRate, int ngs, int oks, decimal oksRatio,int Isqualified); } } diff --git a/ZR.Service/mes/qc/QcRoughService.cs b/ZR.Service/mes/qc/QcRoughService.cs index b38eb0c2..25cdf0cf 100644 --- a/ZR.Service/mes/qc/QcRoughService.cs +++ b/ZR.Service/mes/qc/QcRoughService.cs @@ -1,5 +1,6 @@ using Infrastructure.Attribute; using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Server.HttpSys; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System; @@ -26,36 +27,87 @@ namespace ZR.Service.mes.qu { var predicate = Expressionable.Create() .AndIF(year > 0, wm => wm.Year == year) - .AndIF(week > 0, wm => wm.Week == week) + .AndIF(week > 0, wm => wm.Week == week) .AndIF(date > 0, wm => wm.Date == date) .ToExpression(); int totalCount = 0; //联表查询 - List mr_QusList = Context.Queryable() - .LeftJoin((wm, qc) =>wm.Id==qc.FkMaterialrequisitionId) - .Where(predicate) - .Select((wm,qc) => new Mr_QuRoughDTO { - Id = qc.Id, - FkMaterialrequisitionId=qc.FkMaterialrequisitionId, - Workblankpartnumber=wm.Workblankpartnumber, - Requirenum=wm.Requirenum, - Status = wm.Status, - Year = wm.Year, - Week = wm.Week, - Date = wm.Date, - RequireNum= qc.RequireNum, - ActualNumber=qc.ActualNumber, - RandomRate = qc.RandomRate, - Oks = qc.Oks, - Ngs = qc.Ngs, - OksRatio = qc.OksRatio, - IsFeeding = qc.IsFeeding - }) - .ToPageList(pageNum, pageSize, ref totalCount); + List mr_QusList = Context.Queryable() + .RightJoin((wm, qc) => wm.Id == qc.FkMaterialrequisitionId) + .Where(predicate) + .Select((wm, qc) => new Mr_QuRoughDTO + { + Id = qc.Id, + FkMaterialrequisitionId = qc.FkMaterialrequisitionId, + Workblankpartnumber = wm.Workblankpartnumber, + + Status = wm.Status, + Year = wm.Year, + Week = wm.Week, + Date = wm.Date, + RequireNum = qc.RequireNum, + ActualNumber = qc.ActualNumber, + RandomRate = qc.RandomRate, + Oks = qc.Oks, + Ngs = qc.Ngs, + OksRatio = qc.OksRatio, + IsFeeding = qc.IsFeeding + }) + .ToPageList(pageNum, pageSize, ref totalCount); return (mr_QusList, totalCount); } + + public int UpdateStatisticsTable(string id, int actualNumber, int randomRate, int ngs, int oks, decimal oksRatio, int Isqualified) + { + UseTran(() => + { + QcRough qr = Queryable().Where(it => it.Id == id).First(); + if (qr != null) + { + //更新 领料单状态 + if (Isqualified == 1) + { + Context.Updateable().SetColumns(it => it.Status == "1").Where(it => it.Id == qr.FkMaterialrequisitionId); + } + else if (Isqualified == 0) + { + //不合格,依然处于未领料 + + //新增退料单 + WmMaterialrequisition materialrequisition = Context.Queryable().Where(it => it.Id == qr.FkMaterialrequisitionId).First(); + + + WmMaterialreturn materialreturn = new WmMaterialreturn(); + materialreturn.Id = DateTime.Now.ToString("yyyyMMdd"); + materialreturn.FkMrqrId = qr.FkMaterialrequisitionId; + materialreturn.Year = materialrequisition.Year; + materialreturn.Week = materialrequisition.Week; + materialreturn.Date = materialrequisition.Date; + materialreturn.Workblankpartnumber = materialrequisition.Workblankpartnumber; + materialreturn.Requirenum = materialrequisition.Requirenum; + + Context.Insertable(materialrequisition).ExecuteCommandAsync(); + + } + } + + + + }); + + + return Context.Updateable() + .SetColumns(it => it.ActualNumber == actualNumber) + .SetColumns(it => it.RandomRate == randomRate) + .SetColumns(it => it.Ngs == ngs) + .SetColumns(it => it.Oks == oks) + .SetColumns(it => it.OksRatio == oksRatio) + .Where(it => it.Id == id).ExecuteCommand(); + + + } } }