投料保存 领料记录
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
@@ -335,7 +338,7 @@ namespace Tnb.ProductionMgr
|
||||
/// <exception cref="Exception"></exception>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> Feeding(MaterialReceiptNewInput input)
|
||||
public async Task<dynamic> Feeding(FeedingInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
@@ -375,7 +378,7 @@ namespace Tnb.ProductionMgr
|
||||
station_id = input.station_id,
|
||||
mo_task_id = moTask.id,
|
||||
process_id = moTask.process_id,
|
||||
equip_id = input.equip_id,
|
||||
// equip_id = input.equip_id,
|
||||
workshop_id = workshop?.Id,
|
||||
carry_id = carry.id,
|
||||
workline_id = moTask.workline_id,
|
||||
@@ -389,24 +392,24 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
// if (!inputMaterials.Contains(item["material_id"]))
|
||||
// {
|
||||
// throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
// }
|
||||
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
decimal num = item.codeqty;
|
||||
list.Add(new PrdFeedingD
|
||||
{
|
||||
feeding_id = prdFeedingH.id,
|
||||
material_receipt_detail_id = detail?.id,
|
||||
material_id = item["material_id"],
|
||||
material_id = item.material_id,
|
||||
num = num,
|
||||
batch = item["batch"],
|
||||
unit_id = item["unit_id"],
|
||||
batch = item.code_batch,
|
||||
unit_id = item.unit_id,
|
||||
carry_id = carry.id,
|
||||
status = "0",
|
||||
use_num = 0,
|
||||
@@ -440,7 +443,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收物料");
|
||||
throw new Exception("没有签收物料,无法投料");
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +453,7 @@ namespace Tnb.ProductionMgr
|
||||
});
|
||||
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -496,5 +499,110 @@ namespace Tnb.ProductionMgr
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pad app 领料记录列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> FeedingRecordList(FeedingRecordListInput input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.stationId))
|
||||
{
|
||||
return new
|
||||
{
|
||||
pagination = new PageResult(),
|
||||
list = Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string? code = queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
// DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
|
||||
// DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
|
||||
|
||||
if (string.IsNullOrEmpty(input.sidx))
|
||||
{
|
||||
input.sidx = "create_time";
|
||||
input.sort = "desc";
|
||||
}
|
||||
|
||||
var queryable1 = db.Queryable<PrdKittingOutH>()
|
||||
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
|
||||
.Select((a, b) => new FeedingRecordListOutput()
|
||||
{
|
||||
id = a.id,
|
||||
code = a.code,
|
||||
type_name = "齐套出库",
|
||||
type = "0",
|
||||
create_name = b.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
status = a.status
|
||||
});
|
||||
|
||||
var queryable2 = db.Queryable<PrdOutstockH>()
|
||||
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
|
||||
.Select((a, b) => new FeedingRecordListOutput()
|
||||
{
|
||||
id = a.id,
|
||||
code = a.bill_code,
|
||||
type_name = a.type=="1" ? "一般出库" : "物料出库",
|
||||
type = a.type,
|
||||
create_name = b.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
status = a.status
|
||||
});
|
||||
var result = await db.UnionAll(queryable1,queryable2)
|
||||
.MergeTable()
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
return PageResult<FeedingRecordListOutput>.SqlSugarPageResult(result);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetFeedingRecordInFoById(FeedingRecordInfoInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
if (input.type == "0")
|
||||
{
|
||||
var result = db.Queryable<PrdKittingOutD>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<DictionaryTypeEntity>((a,b,c)=>c.EnCode==DictConst.MeasurementUnit)
|
||||
.LeftJoin<DictionaryDataEntity>((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id)
|
||||
.Where((a, b) => a.kitting_out_id == input.id)
|
||||
.Select((a, b,c,d) => new FeedingRecordInfoOutput
|
||||
{
|
||||
id = a.id,
|
||||
material_id = a.material_id,
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
num = a.pr_qty,
|
||||
unit_name = d.FullName
|
||||
}).ToListAsync();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = db.Queryable<PrdOutstockD>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<DictionaryTypeEntity>((a,b,c)=>c.EnCode==DictConst.MeasurementUnit)
|
||||
.LeftJoin<DictionaryDataEntity>((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id)
|
||||
.Where((a, b) => a.outstock_id == input.id)
|
||||
.Select((a, b,c,d) => new FeedingRecordInfoOutput
|
||||
{
|
||||
id = a.id,
|
||||
material_id = a.material_id,
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
num = a.pr_qty,
|
||||
unit_name = d.FullName
|
||||
}).ToListAsync();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user