diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs new file mode 100644 index 00000000..fbade7ef --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Mvc; +using Model.DBModel; +using ZR.Model.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; + } + + /// + /// 获取生产计划列表 + /// + /// 页编号 + /// 页大小 + /// 年份 + /// 周数 + /// 零件号 + /// 颜色 + /// + [HttpGet("list")] + public IActionResult List(int pageNum, int pageSize, int year = -1, int week = -1, string partNumber = "", string color = "") + { + (List, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color); + + return ToResponse(new ApiResult(200, "success", data)); + } + + } +} diff --git a/ZR.Model/MES/pro/ProWorklplan_v2.cs b/ZR.Model/MES/pro/ProWorklplan_v2.cs new file mode 100644 index 00000000..542a63d0 --- /dev/null +++ b/ZR.Model/MES/pro/ProWorklplan_v2.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using SqlSugar; + +/* + * @author : xkdong@163.com + * @date : 2024-1-12 + * @desc : 生产计划v2 + */ +namespace Model.DBModel +{ + /// + /// 生产计划v2 + /// + [SugarTable("pro_workplan_v2", TableDescription = "生产计划v2")] + public class ProWorklplan_v2 + { + + + /// + /// WP2024030001 + /// + [SugarColumn(IsIdentity = true, IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 零件号 + /// + public string Partnumber { get; set; } + + /// + /// 产品描述 + /// + [SugarColumn(ColumnName = "product_name")] + public string ProductName { get; set; } + + /// + /// 颜色代码 + /// + [SugarColumn(ColumnName = "color_code")] + public string ColorCode { get; set; } + + /// + /// 本周要货数量 + /// + + [SugarColumn(ColumnName = "require_num")] + public float RequireNum { get; set; } + + /// + /// 产品合格率 + /// + + [SugarColumn(ColumnName = "qualification_rate")] + public float QualificationRate { get; set; } + + /// + /// 每挂数量 + /// + + [SugarColumn(ColumnName = "every_hanger_num")] + public float EveryHangerNum { get; set; } + + /// + /// 生产节拍(分钟) + /// + [SugarColumn(ColumnName = "production_beat")] + public decimal ProductionBeat { get; set; } + + /// + /// 总挂具数 + /// + [SugarColumn(ColumnName = "all_hanger_num")] + public float AllHangerNum { get; set; } + + /// + /// 订单需生产挂具数量 + /// + /// + [SugarColumn(ColumnName = "require_hanger")] + public float RequireHanger { get; set; } + + /// + /// 圈数 + /// + /// + [SugarColumn(ColumnName = "turn_number")] + public float TurnNumber { get; set; } + + /// + /// 订单生产时间(分钟) + /// + + [SugarColumn(ColumnName = "product_time")] + public int ProductTime { get; set; } + + + /// + /// 未排程数 + /// + + [SugarColumn(ColumnName = "no_schedule")] + public int NoSchedule { get; set; } + + /// + /// 毛坯号 + /// + + [SugarColumn(ColumnName = "blank_num")] + public int BlankNum { get; set; } + + + + /// + /// 年 + /// + /// + [SugarColumn(ColumnName = "year")] + public float Year { get; set; } + + /// + /// 周 + /// + /// + + + [SugarColumn(ColumnName = "week")] + public float Week { get; set; } + + + /// + /// 创建人 + /// + /// + + + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime CreatedTime { get; set; } + + /// + /// 更新人 + /// + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime UpdatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs new file mode 100644 index 00000000..cd95bbeb --- /dev/null +++ b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs @@ -0,0 +1,51 @@ +using Model.DBModel; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.mes.pro; +using ZR.Model.MES.op.DTO; + +namespace ZR.Service.mes.pro.IService +{ + public interface IProWorkplanServiceV2 + { + + public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color); + + /// + /// 根据计划ID,获取对象 + /// + /// + /// + public List GetProWorkplanById(string id); + + public int AddWorkPlan(ProWorkplan proWorkplan); + + public int UpdateWorkPlan(ProWorkplan proWorkplan); + + public int DeleteWorkPlan(string id); + + /// + /// 根据生产计划ID,获取工单列表 + /// + /// + /// + public List GetWorkorderListByPlanId(string id); + + /// + /// 根据工单ID,获取工单 + /// + /// + /// + public List GetWorkorderListById(string id); + + public int AddWorkorder(ProWorkorder proWorkorder); + + public int UpdateWorkorder(ProWorkorder proWorkorder); + + public int DeleteWorkorder(string id); + } +} diff --git a/ZR.Service/mes/pro/ProWorkplanServiceV2.cs b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs new file mode 100644 index 00000000..bfef2f72 --- /dev/null +++ b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs @@ -0,0 +1,87 @@ +using Infrastructure.Attribute; +using Microsoft.Extensions.DependencyInjection; +using Model.DBModel; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.mes.md; +using ZR.Model.mes.pro; +using ZR.Service.mes.pro.IService; +using ZR.Service.MES.md.IService; + +namespace ZR.Service.mes.pro +{ + + [AppService(ServiceType = typeof(IProWorkplanServiceV2), ServiceLifetime = LifeTime.Transient)] + public class ProWorkplanServiceV2 : BaseService, IProWorkplanServiceV2 + { + + public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color) + { + var predicate = Expressionable.Create() + .AndIF(year > 0, it => it.Year == year) + .AndIF(week > 0, it => it.Week == week) + .AndIF(!string.IsNullOrEmpty(partNumber), it => it.Partnumber.Contains(partNumber)) + .AndIF(!string.IsNullOrEmpty(color), it => it.ColorCode.Contains(color)) + .ToExpression(); + int totalCount = 0; + List proWorkplanList = Context.Queryable().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount); + return (proWorkplanList, totalCount); + } + + + public List GetProWorkplanById(string id) + { + return Context.Queryable().Where(it => it.Id == id).ToList(); + } + + public int AddWorkPlan(ProWorkplan proWorkplan) + { + + proWorkplan.Id = DateTime.Now.ToString("yyyyMMddHHmmss"); + return Context.Insertable(proWorkplan).ExecuteCommand(); + } + + public int UpdateWorkPlan(ProWorkplan proWorkplan) + { + return Context.Updateable(proWorkplan).ExecuteCommand(); + } + + public int DeleteWorkPlan(string id) + { + return Context.Deleteable().In(id).ExecuteCommand(); + } + + public List GetWorkorderListByPlanId(string id) + { + return Context.Queryable().Where(it => it.FkProPlanId == id).OrderBy("priority desc ").ToList(); + } + + public List GetWorkorderListById(string id) + { + return Context.Queryable().Where(it => it.Id == id).ToList(); + } + + public int AddWorkorder(ProWorkorder proWorkorder) + { + + return Context.Insertable(proWorkorder).ExecuteCommand(); + } + + public int UpdateWorkorder(ProWorkorder proWorkorder) + { + return Context.Updateable(proWorkorder).ExecuteCommand(); + } + + public int DeleteWorkorder(string id) + { + return Context.Deleteable().In(id).ExecuteCommand(); + } + + + } +}