导入Excel
This commit is contained in:
parent
a3bca8eb3e
commit
97f4448886
@ -225,9 +225,6 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
int response = _ProWorkorderService.ImportData(formFile, HttpContext.GetName());
|
||||
|
||||
return SUCCESS(response);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//TODO 分批导入工单,追加工单
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Service.MES.group.IService;
|
||||
using DOAN.Service.MES.product;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DOAN.WebApi.Controllers.MES.product
|
||||
{
|
||||
[Verify]
|
||||
[Route("mes/productManagement/ProReportwork")]
|
||||
public class ProweekplanManageController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 周计划表接口
|
||||
/// </summary>
|
||||
private readonly IProweekplanManageService _proweekplanManageService;
|
||||
|
||||
public ProweekplanManageController(IProweekplanManageService proweekplanManageService)
|
||||
{
|
||||
_proweekplanManageService = proweekplanManageService;
|
||||
}
|
||||
|
||||
//TODO excel导入计划
|
||||
/// <summary>
|
||||
/// 导入周计划
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns>导入成功数 若-1 则excel读取异常</returns>
|
||||
[HttpPost("importWeekplan")]
|
||||
[Log(Title = "生产工单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
|
||||
if (formFile == null)
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
int response = _proweekplanManageService.ImportExcel(formFile, HttpContext.GetName());
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
//TODO 导出模板
|
||||
/// <summary>
|
||||
/// 生产工单导入模板下载 workorder 启用(9/14)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "生产周计划导入模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
(string, string) result = DownloadImportTemplate("weekplan");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
|
||||
//TODO 查询计划列表 年周零件号
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
148
DOAN.Model/MES/product/ProWeeklyDatePlan.cs
Normal file
148
DOAN.Model/MES/product/ProWeeklyDatePlan.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Model.MES.product
|
||||
{
|
||||
/// <summary>
|
||||
/// 车间生产日执行表(关联周计划,记录每日计划分解、变更记录、实际完成及报废数据)
|
||||
/// </summary>
|
||||
[SugarTable("pro_weekly_date_plan")]
|
||||
public class ProWeeklyDatePlan
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID,自增唯一标识
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "bigint(20) UNSIGNED", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键ID,自增唯一标识")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联周计划表ID(外键,关联pro_weekly_plan.id)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "bigint(20) UNSIGNED", IsNullable = false, ColumnDescription = "关联周计划表ID(外键,关联pro_weekly_plan.id)")]
|
||||
[Required(ErrorMessage = "关联周计划表ID不能为空")]
|
||||
public ulong FkWeeklyPlanId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周计划编号(冗余存储,如WP202535001,加速查询)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "周计划编号(冗余存储,如WP202535001,加速查询)")]
|
||||
[Required(ErrorMessage = "周计划编号不能为空")]
|
||||
public string PlanCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产日期(如2025-08-25,对应周计划内的具体日期)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "生产日期(如2025-08-25,对应周计划内的具体日期)")]
|
||||
[Required(ErrorMessage = "生产日期不能为空")]
|
||||
public DateTime ProductionDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 班次(如白班、夜班,或班组名:杨惠红班组)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(32)", IsNullable = false, ColumnDescription = "班次(如白班、夜班,或班组名:杨惠红班组)")]
|
||||
[Required(ErrorMessage = "班次不能为空")]
|
||||
public string Shift { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品类型(如车型:Purple,用于分类识别)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "产品类型(如车型:Purple,用于分类识别)")]
|
||||
[Required(ErrorMessage = "产品类型不能为空")]
|
||||
public string ProductType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品编码(如60103250-Y71-16,唯一标识零部件)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "产品编码(如60103250-Y71-16,唯一标识零部件)")]
|
||||
[Required(ErrorMessage = "产品编码不能为空")]
|
||||
public string ProductCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称(冗余存储,如左外后视镜总成)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(100)", IsNullable = true, ColumnDescription = "产品名称(冗余存储,如左外后视镜总成)")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 当日计划生产数量(从周计划分解,或因变更调整)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int(11)", IsNullable = false, ColumnDescription = "当日计划生产数量(从周计划分解,或因变更调整)")]
|
||||
[Required(ErrorMessage = "当日计划生产数量不能为空")]
|
||||
public int DailyPlanQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划是否变更(0:未变更;1:已变更)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint(1)", IsNullable = false, DefaultValue = 0, ColumnDescription = "计划是否变更(0:未变更;1:已变更)")]
|
||||
[Required(ErrorMessage = "计划是否变更不能为空")]
|
||||
public bool IsChanged { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 变更原因(如插单、工艺调整、物料异常)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(255)", IsNullable = true, ColumnDescription = "变更原因(如插单、工艺调整、物料异常)")]
|
||||
public string ChangeReason { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 当日实际完成数量(实时同步自生产报工)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int(11)", IsNullable = false, DefaultValue = 0, ColumnDescription = "当日实际完成数量(实时同步自生产报工)")]
|
||||
public int ActualQty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 当日报废数量(含过程报废和检验报废,用于质量分析)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int(11)", IsNullable = false, DefaultValue = 0, ColumnDescription = "当日报废数量(含过程报废和检验报废,用于质量分析)")]
|
||||
public int ScrapQty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 生产状态(0:未开始;1:执行中;2:已完成;3:暂停)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint(4)", IsNullable = false, ColumnDescription = "生产状态(0:未开始;1:执行中;2:已完成;3:暂停)")]
|
||||
[Required(ErrorMessage = "生产状态不能为空")]
|
||||
public byte ProductionStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作员(工号/姓名,如杨惠红,用于责任追溯)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = true, ColumnDescription = "操作员(工号/姓名,如杨惠红,用于责任追溯)")]
|
||||
public string Operator { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 当日计划执行排序号,决定同日期同班次内的生产先后顺序
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int(11)", IsNullable = false, ColumnDescription = "当日计划执行排序号,决定同日期同班次内的生产先后顺序")]
|
||||
[Required(ErrorMessage = "执行排序号不能为空")]
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人(计划员工号)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "创建人(计划员工号)")]
|
||||
[Required(ErrorMessage = "创建人不能为空")]
|
||||
public string CreatedBy { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "datetime", IsNullable = false, DefaultValue = "CURRENT_TIMESTAMP", ColumnDescription = "创建时间")]
|
||||
[Required(ErrorMessage = "创建时间不能为空")]
|
||||
public DateTime CreatedTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 更新人(工号)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = true, ColumnDescription = "更新人(工号)")]
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新时间(自动触发)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "datetime", IsNullable = true, DefaultValue = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", ColumnDescription = "最后更新时间(自动触发)")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
}
|
||||
223
DOAN.Model/MES/product/ProWeeklyPlan.cs
Normal file
223
DOAN.Model/MES/product/ProWeeklyPlan.cs
Normal file
@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Model.MES.product
|
||||
{
|
||||
/// <summary>
|
||||
/// 周生产计划表(存储汽车零部件每周生产计划,关联ERP订单与车间执行数据)
|
||||
/// </summary>
|
||||
[SugarTable("pro_weekly_plan")]
|
||||
public class ProWeeklyPlan
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID,自增唯一标识
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "bigint", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键ID,自增唯一标识")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周计划编号,业务唯一标识(格式:WP+年份+月份+序号,如WP20250825001)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "周计划编号,业务唯一标识(格式:WP+年份+月份+序号,如WP20250825001)")]
|
||||
[Required(ErrorMessage = "周计划编号不能为空")]
|
||||
public string PlanCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 计划年份(如2025),用于跨年度计划统计
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, ColumnDescription = "计划年份(如2025),用于跨年度计划统计")]
|
||||
[Required(ErrorMessage = "计划年份不能为空")]
|
||||
public int PlanYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划周数(1-53),遵循ISO周历标准,如34表示当年第34周
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, ColumnDescription = "计划周数(1-53),遵循ISO周历标准,如34表示当年第34周")]
|
||||
[Required(ErrorMessage = "计划周数不能为空")]
|
||||
public int PlanWeek { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始日期(固定为周一,如2025-08-25)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "计划开始日期(固定为周一,如2025-08-25)")]
|
||||
[Required(ErrorMessage = "计划开始日期不能为空")]
|
||||
public DateTime PlanStartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束日期(固定为周日,如2025-08-31)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "计划结束日期(固定为周日,如2025-08-31)")]
|
||||
[Required(ErrorMessage = "计划结束日期不能为空")]
|
||||
public DateTime PlanEndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联ERP生产订单号(如PO202508001),用于追溯订单源头
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "关联ERP生产订单号(如PO202508001),用于追溯订单源头")]
|
||||
[Required(ErrorMessage = "关联ERP生产订单号不能为空")]
|
||||
public string OrderCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 零部件编码(企业内部唯一编码,如P-1001-制动盘)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "零部件编码(企业内部唯一编码,如P-1001-制动盘)")]
|
||||
[Required(ErrorMessage = "零部件编码不能为空")]
|
||||
public string ProductCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 零部件名称(如汽车制动盘总成)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(128)", IsNullable = false, ColumnDescription = "零部件名称(如汽车制动盘总成)")]
|
||||
[Required(ErrorMessage = "零部件名称不能为空")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号(如适配车型:B70)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(128)", IsNullable = true, DefaultValue = null, ColumnDescription = "规格型号(如适配车型:B70)")]
|
||||
public string Specification { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品颜色(如高亮黑、珍珠白)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(128)", IsNullable = true, DefaultValue = null, ColumnDescription = "产品颜色(如高亮黑、珍珠白)")]
|
||||
public string Color { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 本周计划生产总数(单位:件)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, ColumnDescription = "本周计划生产总数(单位:件)")]
|
||||
[Required(ErrorMessage = "本周计划生产总数不能为空")]
|
||||
public int PlanQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 累计已完成数量(实时同步自日执行表)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, DefaultValue = 0, ColumnDescription = "累计已完成数量(实时同步自日执行表)")]
|
||||
public int CompletedQty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 剩余未完成数量(自动计算:plan_qty - completed_qty)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, DefaultValue = 0, ColumnDescription = "剩余未完成数量(自动计算:plan_qty - completed_qty)")]
|
||||
public int RemainingQty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 累计报废/报损数量(含过程报废和最终检验报废)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, DefaultValue = 0, ColumnDescription = "累计报废/报损数量(含过程报废和最终检验报废)")]
|
||||
public int ScrapQty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 生产车间编码(如SHGX01),关联车间基础数据表
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "生产车间编码(如SHGX01),关联车间基础数据表")]
|
||||
[Required(ErrorMessage = "生产车间编码不能为空")]
|
||||
public string WorkshopCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产车间名称(如总装车间A区)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "生产车间名称(如总装车间A区)")]
|
||||
[Required(ErrorMessage = "生产车间名称不能为空")]
|
||||
public string WorkshopName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产线编码(如LINE03),标识具体生产流水线
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "生产线编码(如LINE03),标识具体生产流水线")]
|
||||
[Required(ErrorMessage = "生产线编码不能为空")]
|
||||
public string LineCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产线名称(如制动盘装配线)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "生产线名称(如制动盘装配线)")]
|
||||
[Required(ErrorMessage = "生产线名称不能为空")]
|
||||
public string LineName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 计划组别编码(如GRP02),用于计划员分工管理
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "计划组别编码(如GRP02),用于计划员分工管理")]
|
||||
[Required(ErrorMessage = "计划组别编码不能为空")]
|
||||
public string GroupCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 计划组别名称(如底盘件计划组)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "计划组别名称(如底盘件计划组)")]
|
||||
[Required(ErrorMessage = "计划组别名称不能为空")]
|
||||
public string GroupName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 班次类型(1:白班;2:夜班;3:三班倒),标识生产班次模式
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint", IsNullable = false, ColumnDescription = "班次类型(1:白班;2:夜班;3:三班倒),标识生产班次模式")]
|
||||
[Required(ErrorMessage = "班次类型不能为空")]
|
||||
public byte ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划状态(0:未开始;1:执行中;2:已完成;3:暂停;4:取消)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint", IsNullable = false, DefaultValue = 0, ColumnDescription = "计划状态(0:未开始;1:执行中;2:已完成;3:暂停;4:取消)")]
|
||||
[Required(ErrorMessage = "计划状态不能为空")]
|
||||
public byte PlanStatus { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 生产优先级(1:最高;2:正常;3:最低),用于插单排程调整
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint", IsNullable = true, DefaultValue = 2, ColumnDescription = "生产优先级(1:最高;2:正常;3:最低),用于插单排程调整")]
|
||||
public byte? Priority { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行排序号,决定同周内多计划的生产先后顺序
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "int", IsNullable = false, ColumnDescription = "计划执行排序号,决定同周内多计划的生产先后顺序")]
|
||||
[Required(ErrorMessage = "计划执行排序号不能为空")]
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料齐套状态(0:未齐套;1:已齐套;2:部分齐套),影响计划可执行性
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "tinyint", IsNullable = true, DefaultValue = 0, ColumnDescription = "物料齐套状态(0:未齐套;1:已齐套;2:部分齐套),影响计划可执行性")]
|
||||
public byte? MaterialReady { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 备注信息(如特殊工艺要求、主机厂交付节点提醒等)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "text", IsNullable = true, ColumnDescription = "备注信息(如特殊工艺要求、主机厂交付节点提醒等)")]
|
||||
public string? Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人(计划员工号,如EMP00123)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = false, ColumnDescription = "创建人(计划员工号,如EMP00123)")]
|
||||
[Required(ErrorMessage = "创建人不能为空")]
|
||||
public string CreatedBy { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 计划创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "datetime", IsNullable = false, DefaultValue = "CURRENT_TIMESTAMP", ColumnDescription = "计划创建时间")]
|
||||
[Required(ErrorMessage = "创建时间不能为空")]
|
||||
public DateTime CreatedTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新人(工号)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(64)", IsNullable = true, ColumnDescription = "最后更新人(工号)")]
|
||||
public string? UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新时间(自动触发)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "datetime", IsNullable = true, DefaultValue = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", ColumnDescription = "最后更新时间(自动触发)")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
using DOAN.Model.MES.product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.product.IService
|
||||
{
|
||||
public interface IProweekplanManageService
|
||||
{
|
||||
|
||||
void ImportExcel(IFormFile formFile,string username);
|
||||
}
|
||||
}
|
||||
210
DOAN.Service/MES/product/ProweekplanManageService.cs
Normal file
210
DOAN.Service/MES/product/ProweekplanManageService.cs
Normal file
@ -0,0 +1,210 @@
|
||||
using DOAN.Model.MES.product;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
namespace DOAN.Service.MES.product
|
||||
{
|
||||
|
||||
[AppService(ServiceType = typeof(IProweekplanManageService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ProweekplanManageService : BaseService<ProWorkorder>, IProweekplanManageService
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入Excel
|
||||
/// </summary>
|
||||
/// <param name="formFile"></param>
|
||||
/// <param name="username"></param>
|
||||
public void ImportExcel(IFormFile formFile, string username)
|
||||
{
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
try
|
||||
{
|
||||
IWorkbook workbook = new XSSFWorkbook(stream);
|
||||
ISheet sheet = workbook.GetSheetAt(0);
|
||||
// 处理第2行 获取日期
|
||||
|
||||
IRow secondRow = sheet.GetRow(1);
|
||||
NPOI.SS.UserModel.ICell cell = secondRow.GetCell(0);
|
||||
|
||||
|
||||
|
||||
string title = cell.ToString();
|
||||
//提取括号内的数字
|
||||
int week = extractWeek(title);
|
||||
|
||||
// 遍历每一行
|
||||
for (int row = 6; row <= sheet.LastRowNum; row++)
|
||||
{
|
||||
IRow currentRow = sheet.GetRow(row);
|
||||
if (currentRow != null) // 确保行不为空
|
||||
{
|
||||
//班组
|
||||
string group_name = currentRow.GetCell(0)?.ToString();
|
||||
//车型
|
||||
string part_no = currentRow.GetCell(1)?.ToString();
|
||||
//产品编码
|
||||
string plan_qty_str = currentRow.GetCell(2)?.ToString();
|
||||
//产品名称
|
||||
string plan_start_date_str = currentRow.GetCell(3)?.ToString();
|
||||
//产品零件号
|
||||
string plan_end_date_str = currentRow.GetCell(4)?.ToString();
|
||||
//生产状态
|
||||
string status_str = currentRow.GetCell(5)?.ToString();
|
||||
//车间计划员
|
||||
string planner = currentRow.GetCell(6)?.ToString();
|
||||
//本周计划装配数量
|
||||
double plan_qty = currentRow.GetCell(7).NumericCellValue;
|
||||
//本周实际装配数
|
||||
double actual_qty = currentRow.GetCell(8).NumericCellValue;
|
||||
// 2025/8/25 星期一 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? MondayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期一名称
|
||||
string MondayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Mondayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int MondayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string MondayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int MondayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
// 2025/8/25 星期二 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? TuesdayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期二名称
|
||||
string TuesdayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Tuesdayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int TuesdayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string TuesdayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int TuesdayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
// 2025/8/25 星期三 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? WednesdayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期三名称
|
||||
string WednesdayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Wednesdayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int WednesdayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string WednesdayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int WednesdayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
|
||||
// 2025/8/25 星期四 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? ThursdayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期三名称
|
||||
string ThursdayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Thursdayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int ThursdayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string ThursdayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int ThursdayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
// 2025/8/25 星期五 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? FridayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期三名称
|
||||
string FridayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Fridayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int FridayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string FridayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int FridayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
|
||||
// 2025/8/25 星期六 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? SaturdayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期三名称
|
||||
string SaturdayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Saturdayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int SaturdayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string SaturdayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int SaturdayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
|
||||
// 2025/8/25 星期日 产品类型
|
||||
// 2025/8/25
|
||||
DateTime? SundayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue;
|
||||
// 星期三名称
|
||||
string SundayName = sheet.GetRow(3).GetCell(9)?.ToString();
|
||||
//产品类型
|
||||
string Sundayproducttype = currentRow.GetCell(9).ToString();
|
||||
//计划数量
|
||||
int SundayPlanQty = (int)currentRow.GetCell(10).NumericCellValue;
|
||||
//是否变更
|
||||
string SundayIsChange = currentRow.GetCell(11).ToString();
|
||||
//实际数量
|
||||
int SundayActualQty = (int)currentRow.GetCell(12).NumericCellValue;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int extractWeek(string title)
|
||||
{
|
||||
global::System.Text.RegularExpressions.Match match = Regex.Match(title, @"[((](\d+)[))]");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
string numberStr = match.Groups[1].Value; // 获取第一个捕获组中的内容,即数字部分
|
||||
if (int.TryParse(numberStr, out int weekNumber))
|
||||
{
|
||||
Console.WriteLine("提取到的周数是: " + weekNumber); // 输出: 35
|
||||
return weekNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("括号内不是有效的数字。");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("未找到括号内的数字。");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user