This commit is contained in:
qianhao.xu 2024-01-13 16:14:34 +08:00
parent 7f70f51ab4
commit 2e90b9cf09
4 changed files with 338 additions and 0 deletions

View File

@ -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;
}
/// <summary>
/// 获取生产计划列表
/// </summary>
/// <param name="pageNum">页编号</param>
/// <param name="pageSize">页大小</param>
/// <param name="year">年份</param>
/// <param name="week">周数</param>
/// <param name="partNumber">零件号</param>
/// <param name="color">颜色</param>
/// <returns></returns>
[HttpGet("list")]
public IActionResult List(int pageNum, int pageSize, int year = -1, int week = -1, string partNumber = "", string color = "")
{
(List<ProWorklplan_v2>, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color);
return ToResponse(new ApiResult(200, "success", data));
}
}
}

View File

@ -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
{
/// <summary>
/// 生产计划v2
/// </summary>
[SugarTable("pro_workplan_v2", TableDescription = "生产计划v2")]
public class ProWorklplan_v2
{
/// <summary>
/// WP2024030001
/// </summary>
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public string Id { get; set; }
/// <summary>
/// 零件号
/// </summary>
public string Partnumber { get; set; }
/// <summary>
/// 产品描述
/// </summary>
[SugarColumn(ColumnName = "product_name")]
public string ProductName { get; set; }
/// <summary>
/// 颜色代码
/// </summary>
[SugarColumn(ColumnName = "color_code")]
public string ColorCode { get; set; }
/// <summary>
/// 本周要货数量
/// </summary>
[SugarColumn(ColumnName = "require_num")]
public float RequireNum { get; set; }
/// <summary>
/// 产品合格率
/// </summary>
[SugarColumn(ColumnName = "qualification_rate")]
public float QualificationRate { get; set; }
/// <summary>
/// 每挂数量
/// </summary>
[SugarColumn(ColumnName = "every_hanger_num")]
public float EveryHangerNum { get; set; }
/// <summary>
/// 生产节拍(分钟)
/// </summary>
[SugarColumn(ColumnName = "production_beat")]
public decimal ProductionBeat { get; set; }
/// <summary>
/// 总挂具数
/// </summary>
[SugarColumn(ColumnName = "all_hanger_num")]
public float AllHangerNum { get; set; }
/// <summary>
/// 订单需生产挂具数量
/// </summary>
///
[SugarColumn(ColumnName = "require_hanger")]
public float RequireHanger { get; set; }
/// <summary>
/// 圈数
/// </summary>
///
[SugarColumn(ColumnName = "turn_number")]
public float TurnNumber { get; set; }
/// <summary>
/// 订单生产时间(分钟)
/// </summary>
[SugarColumn(ColumnName = "product_time")]
public int ProductTime { get; set; }
/// <summary>
/// 未排程数
/// </summary>
[SugarColumn(ColumnName = "no_schedule")]
public int NoSchedule { get; set; }
/// <summary>
/// 毛坯号
/// </summary>
[SugarColumn(ColumnName = "blank_num")]
public int BlankNum { get; set; }
/// <summary>
/// 年
/// </summary>
///
[SugarColumn(ColumnName = "year")]
public float Year { get; set; }
/// <summary>
/// 周
/// </summary>
///
[SugarColumn(ColumnName = "week")]
public float Week { get; set; }
/// <summary>
/// 创建人
/// </summary>
///
[SugarColumn(ColumnName = "CREATED_BY")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
///
[SugarColumn(ColumnName = "CREATED_TIME")]
public DateTime CreatedTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
///
[SugarColumn(ColumnName = "UPDATED_BY")]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
///
[SugarColumn(ColumnName = "UPDATED_TIME")]
public DateTime UpdatedTime { get; set; }
}
}

View File

@ -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<ProWorklplan_v2>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color);
/// <summary>
/// 根据计划ID获取对象
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public List<ProWorkplan> GetProWorkplanById(string id);
public int AddWorkPlan(ProWorkplan proWorkplan);
public int UpdateWorkPlan(ProWorkplan proWorkplan);
public int DeleteWorkPlan(string id);
/// <summary>
/// 根据生产计划ID获取工单列表
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public List<ProWorkorder> GetWorkorderListByPlanId(string id);
/// <summary>
/// 根据工单ID获取工单
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public List<ProWorkorder> GetWorkorderListById(string id);
public int AddWorkorder(ProWorkorder proWorkorder);
public int UpdateWorkorder(ProWorkorder proWorkorder);
public int DeleteWorkorder(string id);
}
}

View File

@ -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<ProWorklplan_v2>, IProWorkplanServiceV2
{
public (List<ProWorklplan_v2>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color)
{
var predicate = Expressionable.Create<ProWorklplan_v2>()
.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<ProWorklplan_v2> proWorkplanList = Context.Queryable<ProWorklplan_v2>().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount);
return (proWorkplanList, totalCount);
}
public List<ProWorkplan> GetProWorkplanById(string id)
{
return Context.Queryable<ProWorkplan>().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<ProWorkplan>().In(id).ExecuteCommand();
}
public List<ProWorkorder> GetWorkorderListByPlanId(string id)
{
return Context.Queryable<ProWorkorder>().Where(it => it.FkProPlanId == id).OrderBy("priority desc ").ToList();
}
public List<ProWorkorder> GetWorkorderListById(string id)
{
return Context.Queryable<ProWorkorder>().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<ProWorkorder>().In(id).ExecuteCommand();
}
}
}