工单打印
This commit is contained in:
@@ -62,5 +62,7 @@ namespace DOAN.Service.MES.product.IService
|
||||
List<WorkOrderBom> SearchBOMNum(string workorder_num);
|
||||
|
||||
int WorkOrderLog(string workorder, string log, string Operator);
|
||||
|
||||
Task<(string, Stream)> ExportPDFByQuestPDFDemo(string[] workorderArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ using DOAN.Repository;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
using Infrastructure.Attribute;
|
||||
|
||||
|
||||
|
||||
namespace DOAN.Service.MES.product;
|
||||
|
||||
/// <summary>
|
||||
@@ -89,4 +91,8 @@ public class ProReportworkService : BaseService<ProReportwork01>, IProReportwork
|
||||
|
||||
return predicate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -24,20 +24,14 @@ using NPOI.XWPF.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using NPOI.Util;
|
||||
using DOAN.Infrastructure.Helper;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using Aliyun.OSS;
|
||||
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using System.Reflection;
|
||||
|
||||
using Infrastructure;
|
||||
using Infrastructure.Converter;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using DOAN.Model.MES.product;
|
||||
using QuestPDF;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
|
||||
namespace DOAN.Service.MES.product
|
||||
{
|
||||
@@ -62,31 +56,36 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
|
||||
var predicate = Expressionable.Create<ProWorkorder>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionName), it => it.productionName.Contains(parm.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionCode), it => it.productionCode.Contains(parm.productionCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.RouteCode), it => it.RouteCode == parm.RouteCode)
|
||||
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[0] > DateTime.MinValue, it => it.WorkorderDate >= parm.WorkorderDate[0])
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[1] > DateTime.MinValue, it => it.WorkorderDate <= parm.WorkorderDate[1])
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionName),
|
||||
it => it.productionName.Contains(parm.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionCode),
|
||||
it => it.productionCode.Contains(parm.productionCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.RouteCode), it => it.RouteCode == parm.RouteCode)
|
||||
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[0] > DateTime.MinValue,
|
||||
it => it.WorkorderDate >= parm.WorkorderDate[0])
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[1] > DateTime.MinValue,
|
||||
it => it.WorkorderDate <= parm.WorkorderDate[1])
|
||||
;
|
||||
var query = Queryable()
|
||||
.Where(predicate.ToExpression());
|
||||
.Where(predicate.ToExpression());
|
||||
var finalQuery = Context.Queryable(query)
|
||||
.LeftJoin<BaseMaterialList>((q, m) => q.productionCode == m.Code)
|
||||
.LeftJoin<BaseMaterialList>((q, m, m2) => q.productionName == m2.Name)
|
||||
.LeftJoin<BaseWorkRoute>((q, m, m2, r) => q.RouteCode == r.Code)
|
||||
.LeftJoin<BaseGroup>((q, m, m2, r, g) => q.GroupCode == g.GroupCode)
|
||||
.LeftJoin<BaseUnit>((q, m, m2, r, g, u) => q.Unit == u.UnitCode)
|
||||
.Select((q, m, m2, r, g, u) => new ProWorkorderDto3()
|
||||
{
|
||||
IsMatch_material_code = m.Code,
|
||||
IsMatch_material_name = m2.Name,
|
||||
IsMatch_line = r.Code,
|
||||
IsMatch_group = g.GroupCode,
|
||||
IsMatch_Unit = u.UnitCode,
|
||||
}, true);
|
||||
.LeftJoin<BaseMaterialList>((q, m) => q.productionCode == m.Code)
|
||||
.LeftJoin<BaseMaterialList>((q, m, m2) => q.productionName == m2.Name)
|
||||
.LeftJoin<BaseWorkRoute>((q, m, m2, r) => q.RouteCode == r.Code)
|
||||
.LeftJoin<BaseGroup>((q, m, m2, r, g) => q.GroupCode == g.GroupCode)
|
||||
.LeftJoin<BaseUnit>((q, m, m2, r, g, u) => q.Unit == u.UnitCode)
|
||||
.Select((q, m, m2, r, g, u) => new ProWorkorderDto3()
|
||||
{
|
||||
IsMatch_material_code = m.Code,
|
||||
IsMatch_material_name = m2.Name,
|
||||
IsMatch_line = r.Code,
|
||||
IsMatch_group = g.GroupCode,
|
||||
IsMatch_Unit = u.UnitCode,
|
||||
}, true);
|
||||
|
||||
var response = finalQuery.MergeTable().Distinct().OrderBy(it => it.WorkorderDate).ToPage<ProWorkorderDto3, ProWorkorderDto3>(parm);
|
||||
var response = finalQuery.MergeTable().Distinct().OrderBy(it => it.WorkorderDate)
|
||||
.ToPage<ProWorkorderDto3, ProWorkorderDto3>(parm);
|
||||
|
||||
//var query = Queryable()
|
||||
// .Where(predicate.ToExpression());
|
||||
@@ -138,19 +137,23 @@ namespace DOAN.Service.MES.product
|
||||
public PagedInfo<ProWorkorderDto> GetList_NOCheck(ProWorkorderQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<ProWorkorder>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionName), it => it.productionName.Contains(parm.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionName),
|
||||
it => it.productionName.Contains(parm.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Workorder), it => it.Workorder.Contains(parm.Workorder))
|
||||
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionCode), it => it.productionCode.Contains(parm.productionCode))
|
||||
|
||||
.AndIF(!string.IsNullOrEmpty(parm.productionCode),
|
||||
it => it.productionCode.Contains(parm.productionCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.RouteCode), it => it.RouteCode == parm.RouteCode)
|
||||
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[0] > DateTime.MinValue, it => it.WorkorderDate >= parm.WorkorderDate[0])
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[1] > DateTime.MinValue, it => it.WorkorderDate <= parm.WorkorderDate[1])
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[0] > DateTime.MinValue,
|
||||
it => it.WorkorderDate >= parm.WorkorderDate[0])
|
||||
.AndIF(parm.WorkorderDate != null && parm.WorkorderDate[1] > DateTime.MinValue,
|
||||
it => it.WorkorderDate <= parm.WorkorderDate[1])
|
||||
|
||||
;
|
||||
|
||||
|
||||
var query = Queryable()
|
||||
.Where(predicate.ToExpression()).ToPage<ProWorkorder,ProWorkorderDto>(parm);
|
||||
.Where(predicate.ToExpression()).ToPage<ProWorkorder, ProWorkorderDto>(parm);
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -197,7 +200,7 @@ namespace DOAN.Service.MES.product
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.Operator = model.CreatedBy;
|
||||
Context.Insertable(logObj).ExecuteCommand();*/
|
||||
|
||||
|
||||
var response = Update(model, true);
|
||||
return response;
|
||||
|
||||
@@ -213,11 +216,12 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
DateTime update_time = parm.WorkorderDate.ToLocalTime().Date;
|
||||
|
||||
List<ProWorkorder> proWorkorderList = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == update_time)
|
||||
.Where(it => it.Status == 1)
|
||||
.OrderBy(it => it.Sort).ToList();
|
||||
List<ProWorkorder> proWorkorderList = Context.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == update_time)
|
||||
.Where(it => it.Status == 1)
|
||||
.OrderBy(it => it.Sort).ToList();
|
||||
string maxs = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == update_time)
|
||||
.Where(it => it.Status == 3).Max(it => it.Workorder);
|
||||
.Where(it => it.Status == 3).Max(it => it.Workorder);
|
||||
|
||||
|
||||
if (proWorkorderList != null && proWorkorderList.Count() > 0)
|
||||
@@ -238,6 +242,7 @@ namespace DOAN.Service.MES.product
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return Context.Updateable(proWorkorderList).ExecuteCommand();
|
||||
}
|
||||
|
||||
@@ -253,9 +258,11 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
int result = 0;
|
||||
proWorkorder.Id = XueHua;
|
||||
proWorkorder.WorkorderDate= DOANConvertDate.ConvertLocalDate(proWorkorder.WorkorderDate??DateTime.MinValue);
|
||||
proWorkorder.WorkorderDate =
|
||||
DOANConvertDate.ConvertLocalDate(proWorkorder.WorkorderDate ?? DateTime.MinValue);
|
||||
// 获取 产品代号
|
||||
List<SysDictData> ProductCodeList = Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
List<SysDictData> ProductCodeList =
|
||||
Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
DateTime handleDate = proWorkorder.WorkorderDate.Value;
|
||||
//插入工单
|
||||
if (!string.IsNullOrEmpty(next_id) && next_id != "-1")
|
||||
@@ -264,20 +271,23 @@ namespace DOAN.Service.MES.product
|
||||
UseTran2(() =>
|
||||
{
|
||||
ProWorkorder maxs = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == handleDate)
|
||||
.OrderByDescending(it =>SqlFunc.Right(it.Workorder,3)).First();
|
||||
.OrderByDescending(it => SqlFunc.Right(it.Workorder, 3)).First();
|
||||
int index = 1;
|
||||
if (!string.IsNullOrEmpty(maxs.Workorder))
|
||||
{
|
||||
index = Convert.ToInt32(maxs.Workorder.Substring(maxs.Workorder.Length - 3)) + 1;
|
||||
|
||||
}
|
||||
// proWorkorder.Workorder = "K" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.GroupCode + "_" + proWorkorder.RouteCode + "_" + index.ToString("000");
|
||||
// proWorkorder.Workorder = "K" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.GroupCode + "_" + proWorkorder.RouteCode + "_" + index.ToString("000");
|
||||
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == proWorkorder.productionCode).Select(it => it.DictValue).FirstOrDefault();
|
||||
proWorkorder.Workorder = "K" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.RouteCode + proWorkorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == proWorkorder.productionCode)
|
||||
.Select(it => it.DictValue).FirstOrDefault();
|
||||
proWorkorder.Workorder = "K" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.RouteCode +
|
||||
proWorkorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
|
||||
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.Id == next_id).Select(it => it.Sort.Value).First();
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.Id == next_id)
|
||||
.Select(it => it.Sort.Value).First();
|
||||
// 调整序号
|
||||
Context.Updateable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == handleDate)
|
||||
@@ -296,7 +306,7 @@ namespace DOAN.Service.MES.product
|
||||
logObj.Log = "手动新增";
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.Operator = proWorkorder.CreatedBy;
|
||||
logObj.ChangeTime= DateTime.Now;
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.CreatedBy = proWorkorder.CreatedBy;
|
||||
UseTran2(() =>
|
||||
{
|
||||
@@ -309,10 +319,12 @@ namespace DOAN.Service.MES.product
|
||||
else
|
||||
{
|
||||
// 新增工单
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == handleDate).Max(it => it.Sort.Value);
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == handleDate)
|
||||
.Max(it => it.Sort.Value);
|
||||
|
||||
ProWorkorder maxWorkorder = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == handleDate)
|
||||
.OrderByDescending(it =>SqlFunc.Right(it.Workorder,3)).First();
|
||||
ProWorkorder maxWorkorder = Context.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == handleDate)
|
||||
.OrderByDescending(it => SqlFunc.Right(it.Workorder, 3)).First();
|
||||
|
||||
int index = 0;
|
||||
if (maxWorkorder == null)
|
||||
@@ -328,8 +340,10 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
//proWorkorder.Workorder = "H" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.GroupCode + "_" + proWorkorder.RouteCode + "_" + index.ToString("000");
|
||||
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == proWorkorder.productionCode).Select(it => it.DictValue).FirstOrDefault();
|
||||
proWorkorder.Workorder = "H" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.RouteCode + proWorkorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == proWorkorder.productionCode)
|
||||
.Select(it => it.DictValue).FirstOrDefault();
|
||||
proWorkorder.Workorder = "H" + handleDate.ToString("yyyyMMdd") + "_" + proWorkorder.RouteCode +
|
||||
proWorkorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
|
||||
|
||||
proWorkorder.Status = 1;
|
||||
@@ -342,7 +356,7 @@ namespace DOAN.Service.MES.product
|
||||
logObj.Log = "手动新增";
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.Operator = proWorkorder.CreatedBy;
|
||||
logObj.ChangeTime= DateTime.Now;
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.CreatedBy = proWorkorder.CreatedBy;
|
||||
UseTran2(() =>
|
||||
{
|
||||
@@ -370,7 +384,7 @@ namespace DOAN.Service.MES.product
|
||||
int result = 0;
|
||||
ProWorkorder toMove = Context.Queryable<ProWorkorder>().Where(it => it.Id == id).First();
|
||||
var pervious = Context.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == toMove.WorkorderDate);
|
||||
.Where(it => it.WorkorderDate == toMove.WorkorderDate);
|
||||
|
||||
|
||||
//上移动
|
||||
@@ -389,6 +403,7 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
pervious = pervious.Where(it => it.Sort >= toMove.Sort).OrderBy(it => it.Sort);
|
||||
}
|
||||
|
||||
ProWorkorder exchange = pervious.Skip(1).Take(1).First();
|
||||
if (exchange != null)
|
||||
{
|
||||
@@ -418,7 +433,8 @@ namespace DOAN.Service.MES.product
|
||||
List<ProWorkorder> workorderList = new();
|
||||
DateTime dateValue = DateTime.MinValue;
|
||||
// 获取 产品代号
|
||||
List<SysDictData> ProductCodeList= Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
List<SysDictData> ProductCodeList =
|
||||
Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
try
|
||||
@@ -433,7 +449,9 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
// 将单元格的数字值转换为DateTime
|
||||
dateValue = cell.DateCellValue.Value;
|
||||
#region 读取excel
|
||||
|
||||
#region 读取excel
|
||||
|
||||
// 遍历每一行
|
||||
for (int row = 4; row <= sheet.LastRowNum; row++)
|
||||
{
|
||||
@@ -459,7 +477,7 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//02单位
|
||||
NPOI.SS.UserModel.ICell currentCell_04 = currentRow.GetCell(2);
|
||||
|
||||
@@ -590,6 +608,7 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//13 线别code
|
||||
NPOI.SS.UserModel.ICell currentCell_20 = currentRow.GetCell(13);
|
||||
|
||||
@@ -626,7 +645,8 @@ namespace DOAN.Service.MES.product
|
||||
workorder.Priority = 2;
|
||||
|
||||
}
|
||||
else if (currentCell_21.StringCellValue == "正常" || string.IsNullOrEmpty(currentCell_11.StringCellValue))
|
||||
else if (currentCell_21.StringCellValue == "正常" ||
|
||||
string.IsNullOrEmpty(currentCell_11.StringCellValue))
|
||||
{
|
||||
workorder.Priority = 1;
|
||||
|
||||
@@ -657,10 +677,12 @@ namespace DOAN.Service.MES.product
|
||||
workorder.Status = 1;
|
||||
//工单 2024-9-13-组-线-序号
|
||||
int index = (row - 3);
|
||||
string nickCode= ProductCodeList.Where(it=>it.DictLabel==workorder.productionCode).Select(it=>it.DictValue).FirstOrDefault();
|
||||
workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode+ workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == workorder.productionCode)
|
||||
.Select(it => it.DictValue).FirstOrDefault();
|
||||
workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode +
|
||||
workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
workorder.Sort = index * 10;
|
||||
|
||||
|
||||
|
||||
|
||||
CultureInfo culture = CultureInfo.CurrentCulture;
|
||||
@@ -669,6 +691,7 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -684,6 +707,7 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
|
||||
}
|
||||
|
||||
UseTran2(() =>
|
||||
{
|
||||
|
||||
@@ -706,7 +730,8 @@ namespace DOAN.Service.MES.product
|
||||
DateTime dateValue = DateTime.MinValue;
|
||||
|
||||
// 获取 产品代号
|
||||
List<SysDictData> ProductCodeList = Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
List<SysDictData> ProductCodeList =
|
||||
Context.Queryable<SysDictData>().Where(it => it.DictType == "product_code").ToList();
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
try
|
||||
@@ -730,7 +755,9 @@ namespace DOAN.Service.MES.product
|
||||
if (currentRow != null) // 确保行不为空
|
||||
{
|
||||
ProWorkorder workorder = new ProWorkorder();
|
||||
#region 读取excel
|
||||
|
||||
#region 读取excel
|
||||
|
||||
//00主体品名
|
||||
NPOI.SS.UserModel.ICell currentCell_01 = currentRow.GetCell(0);
|
||||
|
||||
@@ -881,6 +908,7 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//13 线别code
|
||||
NPOI.SS.UserModel.ICell currentCell_20 = currentRow.GetCell(13);
|
||||
|
||||
@@ -917,7 +945,8 @@ namespace DOAN.Service.MES.product
|
||||
workorder.Priority = 2;
|
||||
|
||||
}
|
||||
else if (currentCell_21.StringCellValue == "正常" || string.IsNullOrEmpty(currentCell_11.StringCellValue))
|
||||
else if (currentCell_21.StringCellValue == "正常" ||
|
||||
string.IsNullOrEmpty(currentCell_11.StringCellValue))
|
||||
{
|
||||
workorder.Priority = 1;
|
||||
|
||||
@@ -941,6 +970,7 @@ namespace DOAN.Service.MES.product
|
||||
//18备注
|
||||
NPOI.SS.UserModel.ICell currentCell_012 = currentRow.GetCell(18);
|
||||
workorder.Remark01 = currentCell_012?.StringCellValue;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -960,12 +990,15 @@ namespace DOAN.Service.MES.product
|
||||
int index = (row - 3);
|
||||
|
||||
int flowNum = index +
|
||||
Convert.ToInt16(MaxWorkorder.Workorder.Substring(MaxWorkorder.Workorder.Length - 3, 3));
|
||||
Convert.ToInt16(
|
||||
MaxWorkorder.Workorder.Substring(MaxWorkorder.Workorder.Length - 3, 3));
|
||||
|
||||
//workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.GroupCode + "_" + workorder.RouteCode + "_" + flowNum.ToString("000");
|
||||
//workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.GroupCode + "_" + workorder.RouteCode + "_" + flowNum.ToString("000");
|
||||
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == workorder.productionCode).Select(it => it.DictValue).FirstOrDefault();
|
||||
workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode + workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
string nickCode = ProductCodeList.Where(it => it.DictLabel == workorder.productionCode)
|
||||
.Select(it => it.DictValue).FirstOrDefault();
|
||||
workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode +
|
||||
workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
|
||||
|
||||
workorder.Sort = index * 10 + Convert.ToInt16(MaxWorkorder.Sort);
|
||||
|
||||
@@ -988,6 +1021,7 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
|
||||
}
|
||||
|
||||
UseTran2(() =>
|
||||
{
|
||||
|
||||
@@ -1018,12 +1052,12 @@ namespace DOAN.Service.MES.product
|
||||
public List<BaseMaterialList> GetMaterialInfo(BaseMaterialListQueryDto5 parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<BaseMaterialList>()
|
||||
.OrIF(!string.IsNullOrEmpty(parm.Name_or_Code), it => it.Name.Contains(parm.Name_or_Code))
|
||||
.OrIF(!string.IsNullOrEmpty(parm.Name_or_Code), it => it.Code.Contains(parm.Name_or_Code))
|
||||
;
|
||||
.OrIF(!string.IsNullOrEmpty(parm.Name_or_Code), it => it.Name.Contains(parm.Name_or_Code))
|
||||
.OrIF(!string.IsNullOrEmpty(parm.Name_or_Code), it => it.Code.Contains(parm.Name_or_Code))
|
||||
;
|
||||
|
||||
return Context.Queryable<BaseMaterialList>()
|
||||
.Where(predicate.ToExpression()).Take(20).ToList();
|
||||
.Where(predicate.ToExpression()).Take(20).ToList();
|
||||
|
||||
}
|
||||
|
||||
@@ -1035,16 +1069,16 @@ namespace DOAN.Service.MES.product
|
||||
public List<BaseCustom> GetCustomInfo(BaseCustomQueryDto2 parm)
|
||||
{
|
||||
var predicate = Expressionable
|
||||
.Create<BaseCustom>()
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(parm.CustomNo),
|
||||
it => it.CustomNo.Contains(parm.CustomNo)
|
||||
)
|
||||
//.AndIF(
|
||||
// !string.IsNullOrEmpty(parm.CustomNo),
|
||||
// it => it.CustomName.Contains(parm.CustomNo)
|
||||
//)
|
||||
.And(it => it.Status == 1);
|
||||
.Create<BaseCustom>()
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(parm.CustomNo),
|
||||
it => it.CustomNo.Contains(parm.CustomNo)
|
||||
)
|
||||
//.AndIF(
|
||||
// !string.IsNullOrEmpty(parm.CustomNo),
|
||||
// it => it.CustomName.Contains(parm.CustomNo)
|
||||
//)
|
||||
.And(it => it.Status == 1);
|
||||
|
||||
var response = Context.Queryable<BaseCustom>()
|
||||
.Where(predicate.ToExpression())
|
||||
@@ -1120,22 +1154,24 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
List<WorkOrderBom> workOrderBoms = new List<WorkOrderBom>();
|
||||
List<BaseMaterialBom> baseMaterialBoms = null;
|
||||
ProWorkorder proworkorder = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder_num).First();
|
||||
ProWorkorder proworkorder =
|
||||
Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder_num).First();
|
||||
if (proworkorder != null)
|
||||
{
|
||||
baseMaterialBoms = Context.Queryable<BaseMaterialBom>().Where(it => it.InvCode == proworkorder.productionCode).ToList();
|
||||
baseMaterialBoms = Context.Queryable<BaseMaterialBom>()
|
||||
.Where(it => it.InvCode == proworkorder.productionCode).ToList();
|
||||
|
||||
if (baseMaterialBoms != null && baseMaterialBoms
|
||||
.Count() > 0)
|
||||
.Count() > 0)
|
||||
{
|
||||
foreach (var item in baseMaterialBoms)
|
||||
{
|
||||
WorkOrderBom objectMaterial = new WorkOrderBom();
|
||||
|
||||
objectMaterial.SubInvCode=item.SubInvCode;
|
||||
objectMaterial.SubInvCode = item.SubInvCode;
|
||||
objectMaterial.SubInvName = item.SubInvName;
|
||||
objectMaterial.Iusequantity_Single = item.Iusequantity;
|
||||
float num = float.Parse(item.Iusequantity) * proworkorder.PlanNum.Value;
|
||||
objectMaterial.Iusequantity_Single = item.Iusequantity;
|
||||
float num = float.Parse(item.Iusequantity) * proworkorder.PlanNum.Value;
|
||||
objectMaterial.Iusequantity_All = num.ToString();
|
||||
objectMaterial.BOMVersion = item.BOMVersion;
|
||||
workOrderBoms.Add(objectMaterial);
|
||||
@@ -1169,7 +1205,7 @@ namespace DOAN.Service.MES.product
|
||||
logObj.Log = log;
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.Operator = Operator;
|
||||
logObj.ChangeTime= DateTime.Now;
|
||||
logObj.ChangeTime = DateTime.Now;
|
||||
logObj.CreatedBy = Operator;
|
||||
|
||||
|
||||
@@ -1186,24 +1222,28 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
|
||||
var predicate = Expressionable.Create<ProWorkorder>()
|
||||
.AndIF(!string.IsNullOrEmpty(query.productionName), it => it.productionName.Contains(query.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(query.productionCode), it => it.productionCode.Contains(query.productionCode))
|
||||
.AndIF(!string.IsNullOrEmpty(query.RouteCode), it => it.RouteCode == query.RouteCode)
|
||||
.AndIF(!string.IsNullOrEmpty(query.GroupCode), it => it.GroupCode == query.GroupCode)
|
||||
.AndIF(query.WorkorderDate != null && query.WorkorderDate[0] > DateTime.MinValue, it => it.WorkorderDate >= query.WorkorderDate[0])
|
||||
.AndIF(query.WorkorderDate != null && query.WorkorderDate[1] > DateTime.MinValue, it => it.WorkorderDate <= query.WorkorderDate[1])
|
||||
.AndIF(query.Status>-1,it=>it.Status==query.Status)
|
||||
.AndIF(!string.IsNullOrEmpty(query.productionName),
|
||||
it => it.productionName.Contains(query.productionName))
|
||||
.AndIF(!string.IsNullOrEmpty(query.productionCode),
|
||||
it => it.productionCode.Contains(query.productionCode))
|
||||
.AndIF(!string.IsNullOrEmpty(query.RouteCode), it => it.RouteCode == query.RouteCode)
|
||||
.AndIF(!string.IsNullOrEmpty(query.GroupCode), it => it.GroupCode == query.GroupCode)
|
||||
.AndIF(query.WorkorderDate != null && query.WorkorderDate[0] > DateTime.MinValue,
|
||||
it => it.WorkorderDate >= query.WorkorderDate[0])
|
||||
.AndIF(query.WorkorderDate != null && query.WorkorderDate[1] > DateTime.MinValue,
|
||||
it => it.WorkorderDate <= query.WorkorderDate[1])
|
||||
.AndIF(query.Status > -1, it => it.Status == query.Status)
|
||||
|
||||
;
|
||||
var query2 = Queryable()
|
||||
.Where(predicate.ToExpression());
|
||||
.Where(predicate.ToExpression());
|
||||
|
||||
return Context.Queryable(query2).LeftJoin<ProReportwork>((q, r) => q.Workorder == r.FkWorkorder)
|
||||
.Select((q, r) => new ProWorkorderTranceProgressDto()
|
||||
{
|
||||
PlanNum = q.PlanNum,
|
||||
ActualNum = r.FinishedNum,
|
||||
}, true).ToPage_NO_Convert<ProWorkorderTranceProgressDto>(query);
|
||||
.Select((q, r) => new ProWorkorderTranceProgressDto()
|
||||
{
|
||||
PlanNum = q.PlanNum,
|
||||
ActualNum = r.FinishedNum,
|
||||
}, true).ToPage_NO_Convert<ProWorkorderTranceProgressDto>(query);
|
||||
|
||||
|
||||
}
|
||||
@@ -1218,7 +1258,8 @@ namespace DOAN.Service.MES.product
|
||||
UseTran2(() =>
|
||||
{
|
||||
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.Id == next_id).Select(it => it.Sort.Value).First();
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.Id == next_id)
|
||||
.Select(it => it.Sort.Value).First();
|
||||
Context.Updateable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == proWorkorder.WorkorderDate)
|
||||
.Where(it => it.Sort >= sortNum)
|
||||
@@ -1237,7 +1278,8 @@ namespace DOAN.Service.MES.product
|
||||
{
|
||||
DateTime dateOnly = proWorkorder.WorkorderDate.Value.Date;
|
||||
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == dateOnly).Max(it => it.Sort.Value);
|
||||
int sortNum = Context.Queryable<ProWorkorder>().Where(it => it.WorkorderDate == dateOnly)
|
||||
.Max(it => it.Sort.Value);
|
||||
|
||||
proWorkorder.Sort = sortNum + 10;
|
||||
|
||||
@@ -1257,8 +1299,69 @@ namespace DOAN.Service.MES.product
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<(string, Stream)> ExportPDFByQuestPDFDemo(string[] workorderArray)
|
||||
{
|
||||
|
||||
var dataList = Context.Queryable<ProWorkorder>().Where(it => workorderArray.Contains(it.Workorder))
|
||||
.ToList();
|
||||
if (dataList.Count() == 0)
|
||||
{
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
var ms = new MemoryStream();
|
||||
Settings.License = LicenseType.Community;
|
||||
Settings.CheckIfAllTextGlyphsAreAvailable = false;
|
||||
var document = QuestPDF.Fluent.Document.Create(container =>
|
||||
{
|
||||
for (int i = 0; i < dataList.Count(); i++)
|
||||
{
|
||||
byte[] imageBytes= PrintHelper.CreateBarCode(dataList[i].Workorder, 30, 30);
|
||||
container.Page(page =>
|
||||
{
|
||||
page.Margin(20);
|
||||
page.Content().Column(column =>
|
||||
{
|
||||
|
||||
column.Item().Table(table =>
|
||||
{
|
||||
// Define columns
|
||||
table.ColumnsDefinition(columns =>
|
||||
{
|
||||
columns.RelativeColumn(); // Column 1
|
||||
columns.RelativeColumn(); // Column 2
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
});
|
||||
table.Cell().Row(1).ColumnSpan(8).Image(imageBytes);
|
||||
|
||||
table.Cell().Row(2).Column(2).Text("编号");
|
||||
table.Cell().Row(2).Column(6).Text(dataList[i].Workorder);
|
||||
table.Cell().Row(3).Column(2).Text("炉号");
|
||||
table.Cell().Row(3).Column(6).Text(dataList[i].StoveCode);
|
||||
table.Cell().Row(4).Column(2).Text("数量");
|
||||
table.Cell().Row(4).Column(6).Text(dataList[i].PlanNum);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
document.GeneratePdf(ms);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var fileName = $"工单({DateTime.Now.ToString("yyyyMMdd")}).pdf";
|
||||
return new(fileName, ms);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user