模具设备产品关联
This commit is contained in:
32
EquipMgr/Tnb.EquipMgr.Entities/Dto/ProducttListOutput.cs
Normal file
32
EquipMgr/Tnb.EquipMgr.Entities/Dto/ProducttListOutput.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品列表输出类
|
||||
/// </summary>
|
||||
public class ProductListOutput
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string product_code { get; set; }
|
||||
public string product_name { get; set; }
|
||||
public string product_standard { get; set; }
|
||||
public string product_group { get; set; }
|
||||
public int real_cavity_qty { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 模具列表输出类
|
||||
/// </summary>
|
||||
public class MoldListOutput
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string mold_code { get; set; }
|
||||
public string mold_name { get; set; }
|
||||
public int cavity_qty { get; set; }
|
||||
public int real_cavity_qty { get; set; }
|
||||
}
|
||||
}
|
||||
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldInput.cs
Normal file
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldInput.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class ToolMoldInput
|
||||
{
|
||||
public string mold { get; set; }
|
||||
public string[] equipid { get; set; }
|
||||
public string productid { get; set; }
|
||||
public int real_cavity_qty { get; set; }
|
||||
public string[] productids { get; set; }
|
||||
|
||||
public string[] molds { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
128
EquipMgr/Tnb.EquipMgr.Entities/Entity/BasProduct.cs
Normal file
128
EquipMgr/Tnb.EquipMgr.Entities/Entity/BasProduct.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Contracts;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Entity
|
||||
{ ///<summary>
|
||||
///产品信息
|
||||
///</summary>
|
||||
[SugarTable("bas_product")]
|
||||
public partial class BasProduct : BaseEntity<string>
|
||||
{
|
||||
public BasProduct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品分类ID
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string categoryid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:关联比例
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? relation_ratio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:所属组织
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品规格型号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string product_standard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品类型: 半成品:SemiManufacture 成品:FinishedProduct
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string product_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料ID,BAS_MATERIAL.ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:时间戳(用于并发控制)
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string product_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string product_code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
192
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs
Normal file
192
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Contracts;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Entity
|
||||
{
|
||||
///<summary>
|
||||
///模具信息表
|
||||
///</summary>
|
||||
[SugarTable("tool_molds")]
|
||||
public partial class ToolMolds : BaseEntity<string>
|
||||
{
|
||||
public ToolMolds()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:模穴数
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mold_cavity { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产模数
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? production_modulus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:日定额
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? daily_rate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工时定额(H/PCS)
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? hour_norm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:成长周期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? growth_cycle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具寿命
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mold_life { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具编号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:磨具使用状态
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:保养模次
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? maintain_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:型腔数
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具剩余寿命
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_remaining_life { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:库房编号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string warehosue_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:库位编号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具型号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_type_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
63
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldsEquipment.cs
Normal file
63
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldsEquipment.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Contracts;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Entity
|
||||
{
|
||||
//<summary>
|
||||
///模具设备关联表
|
||||
///</summary>
|
||||
[SugarTable("tool_molds_equipment")]
|
||||
public partial class ToolMoldsEquipment : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldsEquipment() { }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string equipment_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
78
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldsProduct.cs
Normal file
78
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldsProduct.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Contracts;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Entity
|
||||
{
|
||||
///<summary>
|
||||
///模具产品关联表
|
||||
///</summary>
|
||||
[SugarTable("tool_molds_product")]
|
||||
public partial class ToolMoldsProduct : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldsProduct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string product_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际使用型腔数
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? real_cavity_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:产品同组标识
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string product_group { get; set; }
|
||||
}
|
||||
}
|
||||
64
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldProductService.cs
Normal file
64
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldProductService.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IToolMoldProductService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据模具id获取设备集合
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
public Task<List<ProductListOutput>> GetProductLists(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 增加模具产品绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productid"></param>
|
||||
/// <param name="real_cavity_qty"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 批量删除模具产品绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> DetachMoldData(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 产品同组
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveProductGroup(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 取消产品同组
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> CancelProductGroup(ToolMoldInput ToolMoldInput);
|
||||
|
||||
/// <summary>
|
||||
/// 根据产品id获取模具集合
|
||||
/// </summary>
|
||||
/// <param name="productid"></param>
|
||||
/// <returns></returns>
|
||||
public Task<List<MoldListOutput>> GetMoldLists(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 批量删除产品模具绑定
|
||||
/// </summary>
|
||||
/// <param name="molds"></param>
|
||||
/// <param name="productid"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public Task<dynamic> DetachProductData(ToolMoldInput ToolMoldInput);
|
||||
}
|
||||
}
|
||||
33
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs
Normal file
33
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IToolMoldsService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据模具id获取设备集合
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
public Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 增加模具设备绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="equipid"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 批量删除模具设备绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="equipid"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> DetachData(ToolMoldInput ToolMoldInput);
|
||||
}
|
||||
}
|
||||
192
EquipMgr/Tnb.EquipMgr/ToolMoldProductService.cs
Normal file
192
EquipMgr/Tnb.EquipMgr/ToolMoldProductService.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Entities.Entity;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldProductService : IToolMoldProductService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ISqlSugarRepository<ToolMolds> _repository;
|
||||
public ToolMoldProductService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具id获取产品集合
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<ProductListOutput>> GetProductLists(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<BasProduct, ToolMoldsProduct>((a, b) => new object[]
|
||||
{
|
||||
JoinType.Inner, a.id == b.product_id,
|
||||
})
|
||||
.Where((a, b) => b.mold_id == ToolMoldInput.mold)
|
||||
.Select((a, b) => new ProductListOutput
|
||||
{
|
||||
id = a.id,
|
||||
product_code = a.product_code,
|
||||
product_name = a.product_name,
|
||||
product_standard = a.product_standard,
|
||||
product_group=b.product_group,
|
||||
real_cavity_qty = b.real_cavity_qty.HasValue ? b.real_cavity_qty.Value : 0
|
||||
}).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加模具产品绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productid"></param>
|
||||
/// <param name="real_cavity_qty"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var ToolMoldsProduct= await _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(p=>p.mold_id== ToolMoldInput.mold&&p.product_id== ToolMoldInput.productid).FirstAsync();
|
||||
if (ToolMoldsProduct == null)
|
||||
{
|
||||
var entity = new ToolMoldsProduct();
|
||||
entity.id = SnowflakeIdHelper.NextId();
|
||||
entity.mold_id = ToolMoldInput.mold;
|
||||
entity.product_id = ToolMoldInput.productid;
|
||||
entity.real_cavity_qty = ToolMoldInput.real_cavity_qty;
|
||||
entity.create_time = DateTime.Now;
|
||||
entity.create_id = _userManager.UserId;
|
||||
await _repository.AsSugarClient().Insertable<ToolMoldsProduct>(entity).ExecuteCommandAsync();
|
||||
}
|
||||
else {
|
||||
ToolMoldsProduct.real_cavity_qty= ToolMoldInput.real_cavity_qty;
|
||||
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(ToolMoldsProduct).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除模具产品绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> DetachMoldData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
|
||||
await _repository.AsSugarClient().Deleteable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
/// <summary>
|
||||
/// 产品同组
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveProductGroup(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
|
||||
var sign = SnowflakeIdHelper.NextId();
|
||||
arr.ForEach(p => { p.product_group = sign; });
|
||||
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
/// <summary>
|
||||
/// 取消产品同组
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="productids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> CancelProductGroup(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
|
||||
arr.ForEach(p => { p.product_group = string.Empty; });
|
||||
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据产品id获取模具集合
|
||||
/// </summary>
|
||||
/// <param name="productid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<MoldListOutput>> GetMoldLists(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<ToolMolds, ToolMoldsProduct>((a, b) => new object[]
|
||||
{
|
||||
JoinType.Inner, a.id == b.mold_id,
|
||||
})
|
||||
.Where((a, b) => b.product_id == ToolMoldInput.productid)
|
||||
.Select((a, b) => new MoldListOutput
|
||||
{
|
||||
id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
cavity_qty = a.cavity_qty.HasValue ? a.cavity_qty.Value : 0,
|
||||
real_cavity_qty = b.real_cavity_qty.HasValue ? b.real_cavity_qty.Value : 0
|
||||
}).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除产品模具绑定
|
||||
/// </summary>
|
||||
/// <param name="molds"></param>
|
||||
/// <param name="productid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> DetachProductData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => ToolMoldInput.molds.Contains(x.mold_id) && x.product_id == ToolMoldInput.productid).ToList();
|
||||
await _repository.AsSugarClient().Deleteable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
108
EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs
Normal file
108
EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Entities.Entity;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{ /// <summary>
|
||||
/// 模具管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldsService : IToolMoldsService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ISqlSugarRepository<ToolMolds> _repository;
|
||||
public ToolMoldsService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具id获取设备集合
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<EqpEquipment, ToolMoldsEquipment>((a, b) => new object[]
|
||||
{
|
||||
JoinType.Inner, a.id == b.equipment_id,
|
||||
})
|
||||
.Where((a, b) => b.mold_id == ToolMoldInput.mold)
|
||||
.Select((a, b) => new EquipmentListOutput
|
||||
{
|
||||
id = a.id,
|
||||
eqp_code=a.code,
|
||||
eqp_name=a.name
|
||||
}).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加模具设备绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="equipid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var list = new List<ToolMoldsEquipment>();
|
||||
foreach (var equip in ToolMoldInput.equipid)
|
||||
{
|
||||
var entity = new ToolMoldsEquipment();
|
||||
entity.id = SnowflakeIdHelper.NextId();
|
||||
entity.mold_id = ToolMoldInput.mold;
|
||||
entity.equipment_id = equip;
|
||||
entity.create_time = DateTime.Now;
|
||||
entity.create_id = _userManager.UserId;
|
||||
list.Add(entity);
|
||||
}
|
||||
await _repository.AsSugarClient().Insertable<ToolMoldsEquipment>(list).ExecuteCommandAsync();
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除模具设备绑定
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <param name="equipid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> DetachData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var arr = _repository.AsSugarClient().Queryable<ToolMoldsEquipment>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.equipid.Contains(x.equipment_id)).ToList();
|
||||
await _repository.AsSugarClient().Deleteable<ToolMoldsEquipment>(arr).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user