FirstFQCService添加#endregion防止报错
新增原材料入库接口
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Model.MES.wm;
|
||||
using ZR.Model.MES.wm.DTO;
|
||||
using ZR.Service.mes.wm.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.mes.wm
|
||||
{
|
||||
[Route("mes/wm/mrt")]
|
||||
public class MaterialReceiptController : BaseController
|
||||
{
|
||||
private readonly IMaterialReceiptService materialReceiptService;
|
||||
|
||||
public MaterialReceiptController(IMaterialReceiptService materialReceiptService)
|
||||
{
|
||||
this.materialReceiptService = materialReceiptService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成并查询原材料入库单
|
||||
/// </summary>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="week"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getMaterialReceiptList")]
|
||||
public IActionResult GetMaterialReceiptList(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1)
|
||||
{
|
||||
(List<WmMaterialReceiptDTO>, int) data = materialReceiptService.GetWmMaterialReceiptList(pageNum, pageSize, year, week, date);
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存单条数据
|
||||
/// </summary>
|
||||
/// <param name="wmMaterialReceiptDTO">一条记录参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveOneMaterialReceipt")]
|
||||
public IActionResult saveOneMaterialReceipt([FromBody] WmMaterialReceiptDTO wmMaterialReceiptDTO)
|
||||
{
|
||||
int resultInt = materialReceiptService.SaveOneMaterialReceipt(wmMaterialReceiptDTO);
|
||||
if (resultInt == 0)
|
||||
{
|
||||
return ToResponse(new ApiResult((int)ResultCode.GLOBAL_ERROR, "保存失败,数据库操作异常", "保存失败"));
|
||||
}
|
||||
if (resultInt == -1)
|
||||
{
|
||||
return ToResponse(new ApiResult((int)ResultCode.GLOBAL_ERROR, "保存失败,传入参数异常", "保存失败"));
|
||||
}
|
||||
return ToResponse(new ApiResult((int)ResultCode.SUCCESS, "success", "保存成功"));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存整页数据
|
||||
/// </summary>
|
||||
/// <param name="list">整页数据</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("savePageMaterialReceipts")]
|
||||
public IActionResult savePageMaterialReceipts([FromBody] List<WmMaterialReceiptDTO> list)
|
||||
{
|
||||
string resultStr = materialReceiptService.SavePageMaterialReceipts(list);
|
||||
return ToResponse(new ApiResult((int)ResultCode.SUCCESS, "success", resultStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
101
ZR.Model/MES/wm/DTO/WmMaterialReceiptDTO.cs
Normal file
101
ZR.Model/MES/wm/DTO/WmMaterialReceiptDTO.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Model.MES.wm.DTO
|
||||
{
|
||||
public class WmMaterialReceiptDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键(雪花生成)
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单号(外键)
|
||||
/// </summary>
|
||||
public string FkWorkorderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单号排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毛坯号
|
||||
/// </summary>
|
||||
public string BlankNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上件数
|
||||
/// </summary>
|
||||
public int PreviousNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实收
|
||||
/// </summary>
|
||||
public int? ActualNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 抽检数
|
||||
/// </summary>
|
||||
public int? SampleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格数
|
||||
/// </summary>
|
||||
public int? QualifiedNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格率
|
||||
/// </summary>
|
||||
public decimal PassRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库号
|
||||
/// </summary>
|
||||
public string WarehouseNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 货架号
|
||||
/// </summary>
|
||||
public string ShelfNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 层号
|
||||
/// </summary>
|
||||
public string LayerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 库位号
|
||||
/// </summary>
|
||||
public string LocationNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态(0-初态 1-合格 2-不合格)
|
||||
/// </summary>
|
||||
public int? Status { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
public int? Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周
|
||||
/// </summary>
|
||||
public int? Week { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 星期几
|
||||
/// </summary>
|
||||
public int? Day { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string Operator { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
91
ZR.Model/MES/wm/WmMaterialReceipt.cs
Normal file
91
ZR.Model/MES/wm/WmMaterialReceipt.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.MES.wm
|
||||
{
|
||||
/// <summary>
|
||||
/// 原材料入库(毛坯入库表)
|
||||
/// </summary>
|
||||
[SugarTable("wm_material_receipt", TableDescription = "原材料入库(毛坯入库表)")]
|
||||
public class WmMaterialReceipt
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键(雪花生成)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsIdentity = false, IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单号(外键)
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(ColumnName = "fk_workorder2_id")]
|
||||
public string FkWorkorder2Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实收
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "actual_number")]
|
||||
public int? ActualNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 抽检数
|
||||
/// </summary>
|
||||
///
|
||||
[SugarColumn(ColumnName = "sample_number")]
|
||||
public int? SampleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格数
|
||||
/// </summary>
|
||||
///
|
||||
[SugarColumn(ColumnName = "qualified_number")]
|
||||
public int? QualifiedNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格率
|
||||
/// </summary>
|
||||
///
|
||||
[SugarColumn(ColumnName = "pass_rate")]
|
||||
public decimal PassRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位号
|
||||
/// </summary>
|
||||
///
|
||||
[SugarColumn(ColumnName = "fk_warehouse_id")]
|
||||
public string FkWarehouseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态(0-初态 1-合格 2-不合格)
|
||||
/// </summary>
|
||||
///
|
||||
[SugarColumn(ColumnName = "status")]
|
||||
public int? Status { 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; }
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,11 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="mes\md\MdMaterialReceiptService.cs" />
|
||||
<Compile Remove="mes\wm\IService\IMdMaterialReceiptService.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1582,3 +1582,4 @@ namespace ZR.Service.mes.qc
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
20
ZR.Service/mes/wm/IService/IMaterialReceiptService.cs
Normal file
20
ZR.Service/mes/wm/IService/IMaterialReceiptService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.MES.wm;
|
||||
using ZR.Model.MES.wm.DTO;
|
||||
|
||||
namespace ZR.Service.mes.wm.IService
|
||||
{
|
||||
public interface IMaterialReceiptService
|
||||
{
|
||||
public (List<WmMaterialReceiptDTO>, int) GetWmMaterialReceiptList(int pageNum, int pageSize, int year, int week, int day);
|
||||
|
||||
public int SaveOneMaterialReceipt(WmMaterialReceiptDTO wmMaterialReceiptDTO);
|
||||
|
||||
public string SavePageMaterialReceipts(List<WmMaterialReceiptDTO> list);
|
||||
|
||||
}
|
||||
}
|
||||
12
ZR.Service/mes/wm/IService/IMdMaterialReceiptService.cs
Normal file
12
ZR.Service/mes/wm/IService/IMdMaterialReceiptService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Service.mes.md.IService
|
||||
{
|
||||
internal interface IMdMaterialReceiptService
|
||||
{
|
||||
}
|
||||
}
|
||||
144
ZR.Service/mes/wm/MaterialReceiptService.cs
Normal file
144
ZR.Service/mes/wm/MaterialReceiptService.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.MES.pro;
|
||||
using ZR.Model.MES.wm;
|
||||
using ZR.Model.MES.wm.DTO;
|
||||
using ZR.Service.mes.wm.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Service.mes.wm
|
||||
{
|
||||
[AppService(ServiceType = typeof(IMaterialReceiptService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class MaterialReceiptService : BaseService<WmMaterialReceipt>, IMaterialReceiptService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成并查询原材料入库单
|
||||
/// 根据生产工单进行生成,以生产工单为主
|
||||
/// </summary>
|
||||
public (List<WmMaterialReceiptDTO>, int) GetWmMaterialReceiptList(int pageNum, int pageSize, int year, int week, int date)
|
||||
{
|
||||
var predicate = Expressionable.Create<ProWorkorder_v2>()
|
||||
.AndIF(year > 0, pw2 => pw2.Year == year)
|
||||
.AndIF(week > 0, pw2 => pw2.Week == week)
|
||||
.AndIF(date > 0, pw2 => pw2.Date == date)
|
||||
.ToExpression();
|
||||
|
||||
int totalCount = 0;
|
||||
List<WmMaterialReceiptDTO> list = Context.Queryable<ProWorkorder_v2, WmMaterialReceipt>((pw2, wmr) => new object[]
|
||||
{
|
||||
JoinType.Left,
|
||||
pw2.Id == wmr.FkWorkorder2Id
|
||||
})
|
||||
.Where(predicate)
|
||||
.Select((pw2,wmr) => new WmMaterialReceiptDTO
|
||||
{
|
||||
FkWorkorderId = pw2.Id,
|
||||
BlankNumber = pw2.BlankNumber,
|
||||
PreviousNumber = pw2.PreviousNumber,
|
||||
Sort = pw2.Sort,
|
||||
Id = wmr.Id,
|
||||
ActualNumber = wmr.ActualNumber,
|
||||
SampleNumber = wmr.SampleNumber,
|
||||
QualifiedNumber = wmr.QualifiedNumber,
|
||||
PassRate = wmr.PassRate,
|
||||
Status=wmr.Status
|
||||
})
|
||||
.OrderBy(pw2 => pw2.Sort)
|
||||
.ToPageList(pageNum, pageSize, ref totalCount);
|
||||
return (list, totalCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存一条原材料入库单数据
|
||||
/// 如果传来的id为空则新增
|
||||
/// 否则就修改
|
||||
/// 0 =数据库操作异常
|
||||
/// -1=传入参数异常
|
||||
/// </summary>
|
||||
|
||||
public int SaveOneMaterialReceipt(WmMaterialReceiptDTO wmMaterialReceiptDTO)
|
||||
{
|
||||
if(wmMaterialReceiptDTO == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(wmMaterialReceiptDTO.FkWorkorderId == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
WmMaterialReceipt wmMaterialReceipt = new WmMaterialReceipt();
|
||||
wmMaterialReceipt.FkWorkorder2Id = wmMaterialReceiptDTO.FkWorkorderId;
|
||||
wmMaterialReceipt.ActualNumber = wmMaterialReceiptDTO.ActualNumber;
|
||||
wmMaterialReceipt.SampleNumber = wmMaterialReceiptDTO.SampleNumber;
|
||||
wmMaterialReceipt.QualifiedNumber = wmMaterialReceiptDTO.QualifiedNumber;
|
||||
wmMaterialReceipt.FkWarehouseId = wmMaterialReceiptDTO.FkWorkorderId;
|
||||
wmMaterialReceipt.Status = wmMaterialReceiptDTO.Status;
|
||||
|
||||
if (IsIdNull(wmMaterialReceiptDTO))
|
||||
{
|
||||
// XXX 雪花算法WorkId需要不同,可能会出现未知异常;
|
||||
// SnowFlakeSingle.WorkId = 22;
|
||||
wmMaterialReceipt.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
wmMaterialReceipt.CreatedBy = wmMaterialReceiptDTO.Operator;
|
||||
wmMaterialReceipt.UpdatedBy = wmMaterialReceiptDTO.Operator;
|
||||
// XXX 时间为粗略时间
|
||||
wmMaterialReceipt.CreatedTime = DateTime.Now;
|
||||
wmMaterialReceipt.UpdatedTime = DateTime.Now;
|
||||
int effectId = Context.Insertable(wmMaterialReceipt).ExecuteCommand();
|
||||
return effectId;
|
||||
}
|
||||
else
|
||||
{
|
||||
wmMaterialReceipt.Id = wmMaterialReceiptDTO.Id;
|
||||
wmMaterialReceipt.UpdatedBy = wmMaterialReceiptDTO.Operator;
|
||||
wmMaterialReceipt.UpdatedTime = DateTime.Now;
|
||||
int effectId = Context.Updateable(wmMaterialReceipt).ExecuteCommand();
|
||||
return effectId;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存前端一整页(多条)原材料入库单数据
|
||||
/// </summary>
|
||||
public string SavePageMaterialReceipts(List<WmMaterialReceiptDTO> list)
|
||||
{
|
||||
int successCount = 0;
|
||||
int totalCount = list.Count;
|
||||
if(list == null || list.Count == 0)
|
||||
{
|
||||
return $"保存成功:无数据变动!";
|
||||
}
|
||||
for(int index = 1; index <= list.Count; index++)
|
||||
{
|
||||
int effectId = SaveOneMaterialReceipt(list[index]);
|
||||
if (effectId < 1)
|
||||
{
|
||||
return $"保存异常:总共{totalCount}条数据已成功保存{successCount}条数据,异常行数{index}";
|
||||
}
|
||||
}
|
||||
return $"保存成功:成功保存{totalCount}条数据";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断id是否为空
|
||||
/// </summary>
|
||||
///
|
||||
public bool IsIdNull(WmMaterialReceiptDTO wmMaterialReceiptDTO)
|
||||
{
|
||||
if (wmMaterialReceiptDTO.Id is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ("".Equals(wmMaterialReceiptDTO.Id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user