Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -12,6 +12,18 @@ public static class DictConst
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string RegionCategoryStationCode = "workstation";
|
public const string RegionCategoryStationCode = "workstation";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 区域类型-公司Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryCompanyCode = "company";
|
||||||
|
/// <summary>
|
||||||
|
/// 区域类型-车间Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryWorkshopCode = "workshop";
|
||||||
|
/// <summary>
|
||||||
|
/// 区域类型-产线Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryWorklineCode = "workline";
|
||||||
|
/// <summary>
|
||||||
/// 备品备件类型
|
/// 备品备件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SparePartsType = "SparePartsType";
|
public const string SparePartsType = "SparePartsType";
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class WorklineAndEquipTreeOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取节点id.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取节点父id.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string parentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有子级.
|
||||||
|
/// </summary>
|
||||||
|
public bool hasChildren { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置Children.
|
||||||
|
/// </summary>
|
||||||
|
public List<WorklineAndEquipTreeOutput>? children { get; set; } = new List<WorklineAndEquipTreeOutput>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子节点数量.
|
||||||
|
/// </summary>
|
||||||
|
public int num { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为子节点.
|
||||||
|
/// </summary>
|
||||||
|
public bool isLeaf { get; set; } = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,5 +17,11 @@ namespace Tnb.EquipMgr.Interfaces
|
|||||||
/// <param name="dic"></param>
|
/// <param name="dic"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<dynamic> GetListByTypeId(Dictionary<string, string> dic);
|
public Task<dynamic> GetListByTypeId(Dictionary<string, string> dic);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产线和注塑挤出设备树
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> GetWorklineAndEquipTree(Dictionary<string,string> dic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
using Aop.Api.Domain;
|
using Aop.Api.Domain;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
using JNPF.Common.Filter;
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Extras.CollectiveOAuth.Models;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Senparc.NeuChar.ApiHandlers;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.EquipMgr.Entities.Dto;
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
@@ -78,5 +83,67 @@ namespace Tnb.EquipMgr
|
|||||||
return await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(x => typeIdArr.Contains(x.equip_type_id))
|
return await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(x => typeIdArr.Contains(x.equip_type_id))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetWorklineAndEquipTree(Dictionary<string,string> dic)
|
||||||
|
{
|
||||||
|
string equipTypes = dic.ContainsKey("equipTypes") ? dic["equipTypes"] : "";
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
var queryable1 = db.Queryable<OrganizeEntity>()
|
||||||
|
.Where((a) => a.DeleteMark == null && a.Category==DictConst.RegionCategoryWorkshopCode)
|
||||||
|
.Select((a) => new WorklineAndEquipTreeOutput()
|
||||||
|
{
|
||||||
|
id = a.Id,
|
||||||
|
title = a.EnCode+"/"+a.FullName,
|
||||||
|
parentId = "0",
|
||||||
|
hasChildren = SqlFunc.Subqueryable<OrganizeEntity>().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Any(),
|
||||||
|
num = SqlFunc.Subqueryable<OrganizeEntity>().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Count(),
|
||||||
|
isLeaf = false,
|
||||||
|
children = SqlFunc.Subqueryable<OrganizeEntity>().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).ToList(b=>new WorklineAndEquipTreeOutput()
|
||||||
|
{
|
||||||
|
id = b.Id,
|
||||||
|
title = b.EnCode+"/"+b.FullName,
|
||||||
|
parentId = b.ParentId,
|
||||||
|
hasChildren = false,
|
||||||
|
num = 0,
|
||||||
|
isLeaf = true,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
List<WorklineAndEquipTreeOutput> list2 = new List<WorklineAndEquipTreeOutput>();
|
||||||
|
if (!string.IsNullOrEmpty(equipTypes))
|
||||||
|
{
|
||||||
|
string[] equipTypeArr = equipTypes.Split(",");
|
||||||
|
list2 = await db.Queryable<EqpEquipType>()
|
||||||
|
.Where((a) => equipTypeArr.Contains(a.code))
|
||||||
|
.Select((a) => new WorklineAndEquipTreeOutput()
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
title = a.name,
|
||||||
|
parentId = "0",
|
||||||
|
hasChildren = SqlFunc.Subqueryable<EqpEquipment>().Where(b=>b.equip_type_id==a.id).Any(),
|
||||||
|
num = SqlFunc.Subqueryable<EqpEquipment>().Where(b=>b.equip_type_id==a.id).Count(),
|
||||||
|
isLeaf = false,
|
||||||
|
children = SqlFunc.Subqueryable<EqpEquipment>().Where(b=>b.equip_type_id==a.id).ToList(b=>new WorklineAndEquipTreeOutput()
|
||||||
|
{
|
||||||
|
id = b.id,
|
||||||
|
title = b.code+"/"+b.name,
|
||||||
|
parentId = b.equip_type_id,
|
||||||
|
hasChildren = false,
|
||||||
|
num = 0,
|
||||||
|
isLeaf = true,
|
||||||
|
})
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// var list = await db.UnionAll(queryable1, queryable2).ToListAsync();
|
||||||
|
var list1 = await queryable1.ToListAsync();
|
||||||
|
list1.AddRange(list2);
|
||||||
|
return new AuthResponse(200, "", new Dictionary<string,object>()
|
||||||
|
{
|
||||||
|
["list"] = list1,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,11 @@ using Tnb.ProductionMgr.Interfaces;
|
|||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.Systems.Entitys.System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
||||||
|
using Tnb.BasicData;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -46,54 +51,82 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
|
// {
|
||||||
|
// var db = _repository.AsSugarClient();
|
||||||
|
// VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||||
|
// var data = await _runService.GetListResult(templateEntity, input);
|
||||||
|
// if (data?.list?.Count > 0)
|
||||||
|
// {
|
||||||
|
// var scheduledTypeField = nameof(PrdMoTask.schedule_type);
|
||||||
|
// data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
|
||||||
|
// foreach (var row in data.list)
|
||||||
|
// {
|
||||||
|
// var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
// var pkName = "material_id";
|
||||||
|
// if (dic.ContainsKey(pkName))
|
||||||
|
// {
|
||||||
|
// var materialId = dic[pkName]?.ToString();
|
||||||
|
// var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||||
|
// if (material != null)
|
||||||
|
// {
|
||||||
|
// row["material_id"] = $"{material.code}/{material.name}";
|
||||||
|
// row["materialid"] = material.id;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //模具
|
||||||
|
// if (dic.ContainsKey("mold_id"))
|
||||||
|
// {
|
||||||
|
// var moldId = dic["mold_id"]?.ToString();
|
||||||
|
// var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldId);
|
||||||
|
// if (mold != null)
|
||||||
|
// {
|
||||||
|
// row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
||||||
|
// row["moldid"] = mold.id;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //设备
|
||||||
|
// if (dic.ContainsKey("eqp_id"))
|
||||||
|
// {
|
||||||
|
// var eqpId = dic["eqp_id"]?.ToString();
|
||||||
|
// var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||||
|
// if (eqp != null)
|
||||||
|
// {
|
||||||
|
// row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||||
|
// row["eqpid"] = eqp.id;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return data!;
|
||||||
|
// }
|
||||||
|
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||||
var data = await _runService.GetListResult(templateEntity, input);
|
string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||||
if (data?.list?.Count > 0)
|
string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : "";
|
||||||
|
var result = await db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.TaskStatus)
|
||||||
|
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
|
||||||
|
.LeftJoin<ToolMolds>((a,b,c,d,e)=>a.mold_id==e.id)
|
||||||
|
.LeftJoin<PrdMo>((a,b,c,d,e,f)=>a.mo_id==f.id)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(moTaskStatus), (a, b, c, d) => a.mo_task_status == moTaskStatus)
|
||||||
|
.Where((a,b,c,d,e,f)=>a.schedule_type==1)
|
||||||
|
.Select((a, b, c, d,e,f) => new PrdMoTask
|
||||||
{
|
{
|
||||||
var scheduledTypeField = nameof(PrdMoTask.schedule_type);
|
id = a.id,
|
||||||
data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
|
mo_task_code = a.mo_task_code,
|
||||||
foreach (var row in data.list)
|
material_id = b.code+"/"+b.name,
|
||||||
{
|
mold_id = e.mold_code+"/"+e.mold_name,
|
||||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
mo_task_status = d.FullName,
|
||||||
var pkName = "material_id";
|
plan_qty = f.plan_qty,
|
||||||
if (dic.ContainsKey(pkName))
|
scheduled_qty = a.scheduled_qty,
|
||||||
{
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
var materialId = dic[pkName]?.ToString();
|
return PageResult<PrdMoTask>.SqlSugarPageResult(result);
|
||||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
|
||||||
if (material != null)
|
|
||||||
{
|
|
||||||
row["material_id"] = $"{material.code}/{material.name}";
|
|
||||||
row["materialid"] = material.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//模具
|
|
||||||
if (dic.ContainsKey("mold_id"))
|
|
||||||
{
|
|
||||||
var moldId = dic["mold_id"]?.ToString();
|
|
||||||
var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldId);
|
|
||||||
if (mold != null)
|
|
||||||
{
|
|
||||||
row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
|
||||||
row["moldid"] = mold.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//设备
|
|
||||||
if (dic.ContainsKey("eqp_id"))
|
|
||||||
{
|
|
||||||
var eqpId = dic["eqp_id"]?.ToString();
|
|
||||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
|
||||||
if (eqp != null)
|
|
||||||
{
|
|
||||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
|
||||||
row["eqpid"] = eqp.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data!;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user