修改命名空间
This commit is contained in:
@@ -4,10 +4,8 @@ using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entitys.Entity;
|
||||
using Tnb.BasicData.Entitys.Dto;
|
||||
using Tnb.BasicData.Entitys;
|
||||
using JNPF.Common.Const;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
@@ -53,7 +51,7 @@ namespace Tnb.BasicData
|
||||
.LeftJoin<BasEbomH>((a,b)=>a.ebom_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<BasEbomH>((a,b,c,d)=>a.material_id==d.material_id)
|
||||
.LeftJoin<BasRoute>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasRouteH>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c,d,e,f)=>a.substitute_material_id==f.id)
|
||||
.Where((a,b,c)=>a.ebom_id==queryInput.ebomId)
|
||||
.Select((a,b,c,d,e,f)=>new EbomTreeOutput
|
||||
@@ -62,11 +60,12 @@ namespace Tnb.BasicData
|
||||
material_id_descrip = c.descrip,
|
||||
material_id_remark = c.remark,
|
||||
material_id_unit_id = c.unit_id,
|
||||
material_id_id = c.id,
|
||||
feeding_control = a.feeding_control,
|
||||
loss_rate = a.loss_rate,
|
||||
quantity = a.quantity,
|
||||
require_weight = a.require_weight,
|
||||
route_name = e.Name,
|
||||
route_name = e.name,
|
||||
version = d.version,
|
||||
substitute_material_id = f.name,
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.material_id==a.material_id).Any(),
|
||||
@@ -82,7 +81,7 @@ namespace Tnb.BasicData
|
||||
.LeftJoin<BasEbomH>((a,b)=>a.ebom_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<BasEbomH>((a,b,c,d)=>a.material_id==d.material_id)
|
||||
.LeftJoin<BasRoute>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasRouteH>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c,d,e,f)=>a.substitute_material_id==f.id)
|
||||
.Where((a,b,c)=>b.material_id==queryInput.materialId && a.ebom_id==b.id)
|
||||
.Select((a,b,c,d,e,f)=>new EbomTreeOutput
|
||||
@@ -91,11 +90,12 @@ namespace Tnb.BasicData
|
||||
material_id_descrip = c.descrip,
|
||||
material_id_remark = c.remark,
|
||||
material_id_unit_id = c.unit_id,
|
||||
material_id_id = c.id,
|
||||
feeding_control = a.feeding_control,
|
||||
loss_rate = a.loss_rate,
|
||||
quantity = a.quantity,
|
||||
require_weight = a.require_weight,
|
||||
route_name = e.Name,
|
||||
route_name = e.name,
|
||||
version = d.version,
|
||||
substitute_material_id = f.name,
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.material_id==a.material_id).Any(),
|
||||
@@ -109,9 +109,15 @@ namespace Tnb.BasicData
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据物料ID获取版本号和工艺路线
|
||||
/// </summary>
|
||||
/// <param name="parameters">物料id materialId</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(string materialId)
|
||||
public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(Dictionary<string,string> parameters)
|
||||
{
|
||||
string materialId = parameters["materialId"];
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
// var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||
@@ -121,17 +127,20 @@ namespace Tnb.BasicData
|
||||
// }
|
||||
|
||||
var ebom = await db.Queryable<BasEbomH>()
|
||||
.LeftJoin<BasRoute>((a,b)=>a.route_id==b.id)
|
||||
.LeftJoin<BasRouteH>((a,b)=>a.route_id==b.id)
|
||||
.OrderByDescending((a,b)=>a.create_time)
|
||||
.Where((a,b) => a.material_id == materialId)
|
||||
.Select((a,b)=>new
|
||||
{
|
||||
a.id,
|
||||
a.version,
|
||||
b.Name,
|
||||
}).SingleAsync();
|
||||
b.name,
|
||||
}).FirstAsync();
|
||||
return new Dictionary<string,string>()
|
||||
{
|
||||
["version"] = ebom?.version,
|
||||
["routeName"] = ebom?.Name
|
||||
["routeName"] = ebom?.name,
|
||||
["routeId"] = ebom?.id
|
||||
,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entitys;
|
||||
using Tnb.BasicData.Entitys.Entity;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
@@ -29,60 +27,62 @@ namespace Tnb.BasicData
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(string materialId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var dic = await _dictionaryDataService.GetDicByKey(DictConst.MeasurementUnit);
|
||||
// var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||
// if (momDbLink != null)
|
||||
// {
|
||||
// db = _dbManager.ChangeDataBase(momDbLink);
|
||||
// }
|
||||
|
||||
var ebom = await db.Queryable<BasEbomH>()
|
||||
.LeftJoin<BasRoute>((a,b)=>a.route_id==b.id)
|
||||
.Where((a,b) => a.material_id == materialId)
|
||||
.Select((a,b)=>new
|
||||
{
|
||||
a.id,
|
||||
a.version,
|
||||
b.Name,
|
||||
}).SingleAsync();
|
||||
return new Dictionary<string,string>()
|
||||
{
|
||||
["version"] = ebom?.version,
|
||||
["routeName"] = ebom?.Name,
|
||||
["routeId"] = ebom?.id
|
||||
};
|
||||
}
|
||||
// [HttpPost]
|
||||
// public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(Dictionary<string,string> parameters)
|
||||
// {
|
||||
// string materialId = parameters["materialId"];
|
||||
// var db = _repository.AsSugarClient();
|
||||
// var dic = await _dictionaryDataService.GetDicByKey(DicTypeKey.MeasurementUnit);
|
||||
// // var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||
// // if (momDbLink != null)
|
||||
// // {
|
||||
// // db = _dbManager.ChangeDataBase(momDbLink);
|
||||
// // }
|
||||
//
|
||||
// var ebom = await db.Queryable<BasEbomH>()
|
||||
// .LeftJoin<BasRouteH>((a,b)=>a.route_id==b.id)
|
||||
// .Where((a,b) => a.material_id == materialId)
|
||||
// .Select((a,b)=>new
|
||||
// {
|
||||
// a.id,
|
||||
// a.version,
|
||||
// b.name,
|
||||
// }).SingleAsync();
|
||||
// return new Dictionary<string,string>()
|
||||
// {
|
||||
// ["version"] = ebom?.version,
|
||||
// ["routeName"] = ebom?.name,
|
||||
// ["routeId"] = ebom?.id
|
||||
// };
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task<List<ElementSelectDto>> GetMaterialUnits(string materialId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
var type = await db.Queryable<DictionaryTypeEntity>().Where(x => x.EnCode == DictConst.MeasurementUnit)
|
||||
.SingleAsync();
|
||||
string typeId = type?.Id;
|
||||
var queryable1 = db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryDataEntity>((a,b)=>a.unit_id==b.EnCode && b.DictionaryTypeId==typeId)
|
||||
.Where((a,b) => a.id == materialId)
|
||||
.Select((a,b)=> new ElementSelectDto
|
||||
{
|
||||
value = b.EnCode,
|
||||
label = b.FullName,
|
||||
});
|
||||
var queryable2 = db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryDataEntity>((a,b)=>a.pickunit_id==b.EnCode && b.DictionaryTypeId==typeId)
|
||||
.Where((a,b) => a.id == materialId)
|
||||
.Select((a,b)=> new ElementSelectDto
|
||||
{
|
||||
value = b.EnCode,
|
||||
label = b.FullName,
|
||||
});
|
||||
List<ElementSelectDto> data = await db.Union(queryable1, queryable2).ToListAsync();
|
||||
return data;
|
||||
}
|
||||
// [HttpPost]
|
||||
// public async Task<List<ElementSelectDto>> GetMaterialUnits(Dictionary<string,string> parameters)
|
||||
// {
|
||||
// string materialId = parameters["materialId"];
|
||||
// var db = _repository.AsSugarClient();
|
||||
//
|
||||
// var type = await db.Queryable<DictionaryTypeEntity>().Where(x => x.EnCode == DictConst.MeasurementUnit)
|
||||
// .SingleAsync();
|
||||
// string typeId = type?.Id;
|
||||
// var queryable1 = db.Queryable<BasMaterial>()
|
||||
// .LeftJoin<DictionaryDataEntity>((a,b)=>a.unit_id==b.EnCode && b.DictionaryTypeId==typeId)
|
||||
// .Where((a,b) => a.Id == materialId)
|
||||
// .Select((a,b)=> new ElementSelectDto
|
||||
// {
|
||||
// value = b.EnCode,
|
||||
// label = b.FullName,
|
||||
// });
|
||||
// var queryable2 = db.Queryable<BasMaterial>()
|
||||
// .LeftJoin<DictionaryDataEntity>((a,b)=>a.pickunit_id==b.EnCode && b.DictionaryTypeId==typeId)
|
||||
// .Where((a,b) => a.Id == materialId)
|
||||
// .Select((a,b)=> new ElementSelectDto
|
||||
// {
|
||||
// value = b.EnCode,
|
||||
// label = b.FullName,
|
||||
// });
|
||||
// List<ElementSelectDto> data = await db.Union(queryable1, queryable2).ToListAsync();
|
||||
// return data;
|
||||
// }
|
||||
}
|
||||
}
|
||||
31
BasicData/Tnb.BasicData/MbomService.cs
Normal file
31
BasicData/Tnb.BasicData/MbomService.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产bom
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class MbomService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasMbom> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
public MbomService(
|
||||
ISqlSugarRepository<BasMbom> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
77
BasicData/Tnb.BasicData/RouteService.cs
Normal file
77
BasicData/Tnb.BasicData/RouteService.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料清单
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 701)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class RouteService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasRouteH> _repository;
|
||||
|
||||
private readonly UserManager _userManager;
|
||||
|
||||
public RouteService(
|
||||
UserManager userManager,
|
||||
ISqlSugarRepository<BasRouteH> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发布工艺路线
|
||||
/// </summary>
|
||||
/// <param name="parameters">工艺路线id id</param>
|
||||
[HttpPost]
|
||||
public async Task Publish(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
|
||||
await _repository.UpdateAsync(x => new BasRouteH()
|
||||
{
|
||||
status = "1",
|
||||
}, x => x.id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复制工艺路线
|
||||
/// </summary>
|
||||
/// <param name="parameters">工艺路线id id</param>
|
||||
[HttpPost]
|
||||
public async Task<string> Copy(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
BasRouteH basRouteH = await _repository.GetByIdAsync(id);
|
||||
|
||||
List<BasRouteD> basRouteDs = await _repository.AsSugarClient().Queryable<BasRouteD>().Where(x => x.route_id == id).ToListAsync();
|
||||
|
||||
string newId = SnowflakeIdHelper.NextId();
|
||||
basRouteH.id = newId;
|
||||
basRouteH.code += "_复制的请修改";
|
||||
basRouteH.name += "_复制的请修改";
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(basRouteH);
|
||||
foreach (BasRouteD basRouteD in basRouteDs)
|
||||
{
|
||||
basRouteD.id = SnowflakeIdHelper.NextId();
|
||||
basRouteD.route_id = newId;
|
||||
}
|
||||
|
||||
await _repository.AsSugarClient().Insertable<BasRouteD>(basRouteDs).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
return result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user