调整在线开发,组织获取关联工序列表代码
This commit is contained in:
@@ -28,6 +28,12 @@ namespace Tnb.BasicData.Entities
|
|||||||
/// Nullable:False
|
/// Nullable:False
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string process_id { get; set; }
|
public string process_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工序编码
|
||||||
|
/// </summary>
|
||||||
|
public string process_code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
// /// Desc:工序代码
|
// /// Desc:工序代码
|
||||||
@@ -42,6 +48,10 @@ namespace Tnb.BasicData.Entities
|
|||||||
/// Nullable:False
|
/// Nullable:False
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string station_id { get; set; }
|
public string station_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工位编码
|
||||||
|
/// </summary>
|
||||||
|
public string station_code { get; set; }
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
// /// Desc:工位代码
|
// /// Desc:工位代码
|
||||||
|
|||||||
@@ -62,35 +62,42 @@ namespace Tnb.BasicData
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var result = new List<ProcessListOutput>();
|
var result = new SqlSugarPagedList<ProcessListOutput>();
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
var organize = await db.Queryable<OrganizeEntity>().FirstAsync(it => it.EnCode == input.station_code && it.Category == DictConst.RegionCategoryStationCode);
|
var organize = await db.Queryable<OrganizeEntity>().FirstAsync(it => it.EnCode == input.station_code && it.Category == DictConst.RegionCategoryStationCode);
|
||||||
if (organize != null)
|
if (organize != null)
|
||||||
{
|
{
|
||||||
var processIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).ToListAsync();
|
var whereExpr = Expressionable.Create<BasProcess, BasProcessStation>();
|
||||||
if (processIds?.Count > 0)
|
var curProcessIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).ToListAsync();
|
||||||
|
if (curProcessIds?.Count > 0)
|
||||||
{
|
{
|
||||||
result = await db.Queryable<BasProcess>().Where(it => processIds.Contains(it.id)).Select(it => new ProcessListOutput
|
whereExpr = whereExpr.And((a, b) => curProcessIds.Contains(a.id)).Or((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||||
{
|
|
||||||
id = it.id,
|
|
||||||
process_code = it.process_code,
|
|
||||||
process_name = it.process_name,
|
|
||||||
process_collection = it.process_collection,
|
|
||||||
status = it.status,
|
|
||||||
station = it.station,
|
|
||||||
must_pass = it.must_pass,
|
|
||||||
defective_products_put_into_production = it.defective_products_put_into_production,
|
|
||||||
single_scan_type = it.single_scan_type,
|
|
||||||
only_scan_type = it.only_scan_type,
|
|
||||||
material_traced_back_relationship = it.material_traced_back_relationship,
|
|
||||||
report_template = it.report_template,
|
|
||||||
descrip = it.descrip,
|
|
||||||
org_id = it.org_id,
|
|
||||||
create_id = it.create_id,
|
|
||||||
modify_id = it.modify_id,
|
|
||||||
modify_time = it.modify_time,
|
|
||||||
}).ToListAsync();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
whereExpr = whereExpr.And((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||||
|
}
|
||||||
|
result = await db.Queryable<BasProcess>().LeftJoin<BasProcessStation>((a, b) => a.id == b.process_id).Where(whereExpr.ToExpression()).Select(a => new ProcessListOutput
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
process_code = a.process_code,
|
||||||
|
process_name = a.process_name,
|
||||||
|
process_collection = a.process_collection,
|
||||||
|
status = a.status,
|
||||||
|
station = a.station,
|
||||||
|
must_pass = a.must_pass,
|
||||||
|
defective_products_put_into_production = a.defective_products_put_into_production,
|
||||||
|
single_scan_type = a.single_scan_type,
|
||||||
|
only_scan_type = a.only_scan_type,
|
||||||
|
material_traced_back_relationship = a.material_traced_back_relationship,
|
||||||
|
report_template = a.report_template,
|
||||||
|
descrip = a.descrip,
|
||||||
|
org_id = a.org_id,
|
||||||
|
create_id = a.create_id,
|
||||||
|
modify_id = a.modify_id,
|
||||||
|
modify_time = a.modify_time,
|
||||||
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace Tnb.EquipMgr.Entities
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
9
EquipMgr/Tnb.EquipMgr.Entities/Consts/ModuleConsts.cs
Normal file
9
EquipMgr/Tnb.EquipMgr.Entities/Consts/ModuleConsts.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Consts
|
||||||
|
{
|
||||||
|
public class ModuleConsts
|
||||||
|
{
|
||||||
|
public const string Tag = "EquimentManager";
|
||||||
|
public const string Area = "equiment";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
25
EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs
Normal file
25
EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
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 EquipmentListOutput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string eqp_code { get; set; }
|
||||||
|
public string eqp_name { get; set; }
|
||||||
|
public string eqp_type_code { get; set; }
|
||||||
|
public string accept_status { get; set; }
|
||||||
|
public string supplier_code { get; set; }
|
||||||
|
public string accept_date { get; set; }
|
||||||
|
public string install_date { get; set; }
|
||||||
|
public string use_department_code { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Tnb.EquipMgr.Interfaces
|
namespace Tnb.EquipMgr.Interfaces
|
||||||
{
|
{
|
||||||
public class Class1
|
public interface IEquipmentService
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace Tnb.EquipMgr
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
69
EquipMgr/Tnb.EquipMgr/EquipmentService.cs
Normal file
69
EquipMgr/Tnb.EquipMgr/EquipmentService.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using Aop.Api.Domain;
|
||||||
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.EquipMgr.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities.Consts;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备管理
|
||||||
|
/// </summary>
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
[OverideVisualDev(ModuleId)]
|
||||||
|
|
||||||
|
public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
private const string ModuleId = "25064865727509";
|
||||||
|
private readonly ISqlSugarRepository<EqpEquipment> _repository;
|
||||||
|
|
||||||
|
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
OverideFuncs.GetListAsync = GetList;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 在线开发-获取设备列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
|
{
|
||||||
|
var dic = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "Qualified","合格"},
|
||||||
|
{ "Unqualified","不合格"},
|
||||||
|
};
|
||||||
|
|
||||||
|
var pagedList = await _repository.AsQueryable()
|
||||||
|
.Where(it => it.station_code == input.station_code || string.IsNullOrEmpty(input.station_code))
|
||||||
|
.Select(it => new EquipmentListOutput
|
||||||
|
{
|
||||||
|
id = it.id,
|
||||||
|
eqp_code = it.eqp_code,
|
||||||
|
eqp_name = it.eqp_name,
|
||||||
|
eqp_type_code = it.eqp_type_code,
|
||||||
|
accept_status = it.accept_status,
|
||||||
|
supplier_code = it.supplier_code,
|
||||||
|
accept_date = it.accept_date,
|
||||||
|
install_date = it.install_date,
|
||||||
|
use_department_code = it.use_department_code,
|
||||||
|
remark = it.remark,
|
||||||
|
})
|
||||||
|
.Mapper(it => it.accept_status = dic.ContainsKey(it.accept_status) ? dic[it.accept_status] : "")
|
||||||
|
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
|
return pagedList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using JNPF.Common.Core.Manager;
|
using Aop.Api.Domain;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Filter;
|
using JNPF.Common.Filter;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
@@ -16,7 +17,10 @@ using Mapster;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Senparc.Weixin.MP.AdvancedAPIs.Comment.CommentJson;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
|
|
||||||
namespace JNPF.Systems;
|
namespace JNPF.Systems;
|
||||||
@@ -442,27 +446,54 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
|||||||
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||||
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
|
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
|
||||||
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
|
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
|
||||||
if (input.category == "workstation")
|
if (input.category == DictConst.RegionCategoryStationCode)
|
||||||
{
|
{
|
||||||
var eqpObj = input.propertyJson;
|
var jsonObj = input.propertyJson;
|
||||||
var eqpList = (eqpObj.Value<JArray>("roweqp"));
|
var eqpVal = jsonObj.GetValue("roweqp");
|
||||||
var eqpIds = eqpList.Select(x => x.Value<string>("id")).ToList();
|
if (eqpVal is not null)
|
||||||
|
|
||||||
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync();
|
|
||||||
//工位与设备解绑操作
|
|
||||||
var eqpEntities = await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(it => it.station_code == input.enCode).ToListAsync();
|
|
||||||
if (eqpEntities?.Count > 0)
|
|
||||||
{
|
{
|
||||||
var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
|
var eqpList = (jsonObj.Value<JArray>("roweqp"));
|
||||||
if (unbindEqpIds?.Count > 0)
|
var eqpIds = eqpList.Select(x => x.Value<string>("id")).ToList();
|
||||||
|
|
||||||
|
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
//工位与设备解绑操作
|
||||||
|
var eqpEntities = await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(it => it.station_code == input.enCode).ToListAsync();
|
||||||
|
if (eqpEntities?.Count > 0)
|
||||||
{
|
{
|
||||||
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
|
var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
|
||||||
|
if (unbindEqpIds?.Count > 0)
|
||||||
|
{
|
||||||
|
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var processVal = jsonObj.GetValue("rowprocess");
|
||||||
|
if (processVal is not null)
|
||||||
|
{
|
||||||
|
var dic = _repository.GetList().ToDictionary(x => x.FullName, x => x.Id);
|
||||||
|
var procList = jsonObj.Value<JArray>("rowprocess");
|
||||||
|
var basProcessStationList = procList.Select(x => new BasProcessStation
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
org_id = dic.ContainsKey(x.Value<string>("org_id")) ? dic[x.Value<string>("org_id")] : "",
|
||||||
|
process_id = x.Value<string>("id"),
|
||||||
|
process_code = x.Value<string>("process_code"),
|
||||||
|
station_code = input.enCode,
|
||||||
|
station_id = input.id,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
}).ToList();
|
||||||
|
isOK = await _repository.AsSugarClient().Insertable<BasProcessStation>(basProcessStationList).ExecuteCommandAsync();
|
||||||
|
//工位与工序解绑操作
|
||||||
|
//>1 根据传递的工位Id获取绑定过的工序Id
|
||||||
|
var processIds = await _repository.AsSugarClient().Queryable<BasProcessStation>().Where(it => it.station_id == input.id).Select(it => it.process_id).ToListAsync();
|
||||||
|
var curProcIds = basProcessStationList.Select(x => x.process_id).Except(processIds).ToList();
|
||||||
|
if (curProcIds?.Count > 0)
|
||||||
|
{
|
||||||
|
isOK = await _repository.AsSugarClient().Updateable<BasProcessStation>(it => new BasProcessStation { station_id = "", station_code = "" }).Where(it => curProcIds.Contains(it.process_id)).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001);
|
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 第三方同步
|
#region 第三方同步
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||||
<ProjectReference Include="..\..\common\Tnb.CollectiveOAuth\Tnb.CollectiveOAuth.csproj" />
|
<ProjectReference Include="..\..\common\Tnb.CollectiveOAuth\Tnb.CollectiveOAuth.csproj" />
|
||||||
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
||||||
<ProjectReference Include="..\..\message\Tnb.Message.Interfaces\Tnb.Message.Interfaces.csproj" />
|
<ProjectReference Include="..\..\message\Tnb.Message.Interfaces\Tnb.Message.Interfaces.csproj" />
|
||||||
|
|||||||
@@ -175,22 +175,6 @@ public class RunService : IRunService, ITransient
|
|||||||
input.queryJson = GetQueryJson(input.queryJson, _userManager.UserOrigin == "pc" ? templateInfo.ColumnData : templateInfo.AppColumnData).ToJsonString();
|
input.queryJson = GetQueryJson(input.queryJson, _userManager.UserOrigin == "pc" ? templateInfo.ColumnData : templateInfo.AppColumnData).ToJsonString();
|
||||||
input.superQueryJson = GetSuperQueryJson(input.superQueryJson).ToJsonString();
|
input.superQueryJson = GetSuperQueryJson(input.superQueryJson).ToJsonString();
|
||||||
|
|
||||||
//modified by ly on 20230426
|
|
||||||
var jArr = JArray.Parse(entity.Tables);
|
|
||||||
if (!input.station_code.IsNullOrWhiteSpace())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (jArr?.FirstOrDefault()?.Value<string>("table") == "eqp_equipment")
|
|
||||||
{
|
|
||||||
sql += $" where station_code='{input.station_code}' or station_code=''";
|
|
||||||
}
|
|
||||||
if (jArr?.FirstOrDefault()?.Value<string>("table") == "bas_process")
|
|
||||||
{
|
|
||||||
//sql += $" and station_code='{input.station_code}' or station_code=''";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
realList = _databaseService.GetInterFaceData(link, sql, input, templateInfo.ColumnData.Adapt<MainBeltViceQueryModel>(), new List<IConditionalModel>(), tableFieldKeyValue);
|
realList = _databaseService.GetInterFaceData(link, sql, input, templateInfo.ColumnData.Adapt<MainBeltViceQueryModel>(), new List<IConditionalModel>(), tableFieldKeyValue);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user