点巡检复核
This commit is contained in:
@@ -84,25 +84,47 @@ namespace Tnb.BasicData
|
|||||||
public async Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
|
public async Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
if (!string.IsNullOrEmpty(queryInput.ebom_id))
|
||||||
BasEbomH ebom = await db.Queryable<BasEbomH>().Where(x => x.id == queryInput.ebom_id).SingleAsync();
|
{
|
||||||
ids.Add(ebom.material_id);
|
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
||||||
var result = await db.Queryable<BasMaterial>()
|
BasEbomH ebom = await db.Queryable<BasEbomH>().Where(x => x.id == queryInput.ebom_id).SingleAsync();
|
||||||
.LeftJoin<DictionaryDataEntity>((a, b) => a.unit_id == b.EnCode)
|
ids.Add(ebom.material_id);
|
||||||
.LeftJoin<DictionaryTypeEntity>((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null)
|
var result = await db.Queryable<BasMaterial>()
|
||||||
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
.LeftJoin<DictionaryDataEntity>((a, b) => a.unit_id == b.EnCode)
|
||||||
.WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
|
.LeftJoin<DictionaryTypeEntity>((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null)
|
||||||
.Select((a, b, c) => new MaterialSelectOutput()
|
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
||||||
{
|
.WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
|
||||||
id = a.id,
|
.Select((a, b, c) => new MaterialSelectOutput()
|
||||||
code = a.code,
|
{
|
||||||
name = a.name,
|
id = a.id,
|
||||||
descrip = a.descrip,
|
code = a.code,
|
||||||
unit_id = a.unit_id,
|
name = a.name,
|
||||||
unit_name = b.FullName,
|
descrip = a.descrip,
|
||||||
}).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
|
unit_id = a.unit_id,
|
||||||
|
unit_name = b.FullName,
|
||||||
|
}).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
|
||||||
|
|
||||||
return PageResult<MaterialSelectOutput>.SqlSugarPageResult(result);
|
return PageResult<MaterialSelectOutput>.SqlSugarPageResult(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = await db.Queryable<BasMaterial>()
|
||||||
|
.LeftJoin<DictionaryDataEntity>((a, b) => a.unit_id == b.EnCode)
|
||||||
|
.LeftJoin<DictionaryTypeEntity>((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
||||||
|
.Select((a, b, c) => new MaterialSelectOutput()
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
code = a.code,
|
||||||
|
name = a.name,
|
||||||
|
descrip = a.descrip,
|
||||||
|
unit_id = a.unit_id,
|
||||||
|
unit_name = b.FullName,
|
||||||
|
}).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
|
||||||
|
|
||||||
|
return PageResult<MaterialSelectOutput>.SqlSugarPageResult(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class SpotInsRecordExecuteInput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
public string attachment { get; set; }
|
||||||
|
|
||||||
|
public string result { get; set; }
|
||||||
|
|
||||||
|
public string result_remark { get; set; }
|
||||||
|
|
||||||
|
public List<Dictionary<string,string>> details { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class SpotInsRecordRepeatInput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
public string repeat_result { get; set; }
|
||||||
|
|
||||||
|
public string repeat_remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class SpotInsRecordRepeatOutput
|
||||||
|
{
|
||||||
|
public EqpSpotInsRecordH model { get; set; }
|
||||||
|
|
||||||
|
public List<EqpSpotInsRecordD> details { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@ namespace Tnb.EquipMgr.Entities
|
|||||||
/// Default:
|
/// Default:
|
||||||
/// Nullable:True
|
/// Nullable:True
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? result {get;set;}
|
public string? result {get;set;}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:点巡检结果备注
|
/// Desc:点巡检结果备注
|
||||||
@@ -219,6 +219,13 @@ namespace Tnb.EquipMgr.Entities
|
|||||||
/// Nullable:True
|
/// Nullable:True
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? attachment {get;set;}
|
public string? attachment {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:复核结果1 合格2不合格
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string? repeat_result {get;set;}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using JNPF.Common.Dtos.VisualDev;
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
|
|
||||||
namespace Tnb.EquipMgr.Interfaces
|
namespace Tnb.EquipMgr.Interfaces
|
||||||
{
|
{
|
||||||
@@ -9,6 +10,21 @@ namespace Tnb.EquipMgr.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pageInput"></param>
|
/// <param name="pageInput"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<dynamic> ExecuteSpotIns(string id,VisualDevModelDataUpInput input);
|
public Task<dynamic> ExecuteSpotIns(SpotInsRecordExecuteInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取点巡检复核信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dic"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<SpotInsRecordRepeatOutput> GetSpotInsRecordRepeatInfo(Dictionary<string, string> dic);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 复核点巡检
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task RepeatSpotIns(SpotInsRecordRepeatInput input);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,20 +25,24 @@ namespace Tnb.EquipMgr
|
|||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
|
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
|
||||||
IUserManager userManager,
|
IUserManager userManager)
|
||||||
IVisualDevService visualDevService)
|
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据模板id发布到设备
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dic"></param>
|
||||||
|
[HttpPost]
|
||||||
public async Task<string> Publish(SpotInsTemPublishInput input)
|
public async Task<string> Publish(SpotInsTemPublishInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||||
List<EqpSpotInsTemD> eqpSpotInsTemDs = await db.Queryable<EqpSpotInsTemD>().Where(x=>x.spot_ins_item_id==input.id).ToListAsync();
|
List<EqpSpotInsTemD> eqpSpotInsTemDs = await db.Queryable<EqpSpotInsTemD>().Where(x=>x.spot_ins_tem_id==input.id).ToListAsync();
|
||||||
|
|
||||||
if (input.equipIds != null && input.equipIds.Length > 0)
|
if (input.equipIds != null && input.equipIds.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -47,7 +51,7 @@ namespace Tnb.EquipMgr
|
|||||||
foreach (var equipId in input.equipIds)
|
foreach (var equipId in input.equipIds)
|
||||||
{
|
{
|
||||||
string id = SnowflakeIdHelper.NextId();
|
string id = SnowflakeIdHelper.NextId();
|
||||||
string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}";
|
string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
|
||||||
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
|
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
|
||||||
{
|
{
|
||||||
id = id,
|
id = id,
|
||||||
@@ -82,12 +86,17 @@ namespace Tnb.EquipMgr
|
|||||||
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
|
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
|
||||||
{
|
{
|
||||||
id = SnowflakeIdHelper.NextId(),
|
id = SnowflakeIdHelper.NextId(),
|
||||||
spot_ins_item_id = eqpSpotInsTem.id,
|
spot_ins_item_id = eqpSpotInsTem.spot_ins_item_id,
|
||||||
spot_ins_tem_equip_id = id,
|
spot_ins_tem_equip_id = id,
|
||||||
};
|
};
|
||||||
insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD);
|
insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EqpSpotInsTemEquipH oldSpotInsTemEquipH = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id == equipId).FirstAsync();
|
||||||
|
await db.Deleteable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
|
||||||
|
if(oldSpotInsTemEquipH!=null)
|
||||||
|
await db.Deleteable<EqpSpotInsTemEquipD>().Where(x => x.spot_ins_tem_equip_id==oldSpotInsTemEquipH.id).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
|
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.EquipMgr
|
namespace Tnb.EquipMgr
|
||||||
@@ -39,24 +40,20 @@ namespace Tnb.EquipMgr
|
|||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
// OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<dynamic> ExecuteSpotIns(string id,[FromBody]VisualDevModelDataUpInput input)
|
/// <summary>
|
||||||
|
/// 执行点巡检
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> ExecuteSpotIns(SpotInsRecordExecuteInput input)
|
||||||
{
|
{
|
||||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
//string attachment = JsonConvert.SerializeObject(input.data["attachment"]);
|
EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.id);
|
||||||
// _repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
|
||||||
// {
|
|
||||||
// result = (int)input.data["result"],
|
|
||||||
// attachment = attachment,
|
|
||||||
// result_remark = input.data["result_remark"].ToString(),
|
|
||||||
// }, x => x.id == input.data["id"]);
|
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
|
||||||
await _runService.Update(id,templateEntity, input);
|
|
||||||
|
|
||||||
EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.data["id"].ToString());
|
|
||||||
string status = "";
|
string status = "";
|
||||||
if (eqpSpotInsRecordH.is_repeat == "1")
|
if (eqpSpotInsRecordH.is_repeat == "1")
|
||||||
{
|
{
|
||||||
@@ -66,17 +63,68 @@ namespace Tnb.EquipMgr
|
|||||||
{
|
{
|
||||||
status = SpotInsRecordExecutionStatus.COMPLETED;
|
status = SpotInsRecordExecutionStatus.COMPLETED;
|
||||||
}
|
}
|
||||||
_repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
await _repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||||
{
|
{
|
||||||
status = status,
|
result = input.result,
|
||||||
spot_record_date_time = DateTime.Now,
|
attachment = input.attachment,
|
||||||
spot_record_user_id = _userManager.UserId
|
result_remark = input.result_remark,
|
||||||
}, x => x.id == input.data["id"]);
|
status = status,
|
||||||
|
spot_record_date_time = DateTime.Now,
|
||||||
|
spot_record_user_id = _userManager.UserId
|
||||||
|
}, x => x.id == input.id);
|
||||||
|
|
||||||
|
foreach (var item in input.details)
|
||||||
|
{
|
||||||
|
await _repository.AsSugarClient().Updateable<EqpSpotInsRecordD>().
|
||||||
|
SetColumns(x=>x.result==item["result"])
|
||||||
|
.SetColumnsIF(item["judge_type"]=="1",x=>x.real_value==Convert.ToDouble(item["real_value"]))
|
||||||
|
.Where(x=>x.id==item["id"])
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||||
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
|
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取点巡检复核信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dic"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<SpotInsRecordRepeatOutput> GetSpotInsRecordRepeatInfo(Dictionary<string, string> dic)
|
||||||
|
{
|
||||||
|
string id = dic["id"];
|
||||||
|
EqpSpotInsRecordH eqpSpotInsRecordH = await _repository.GetSingleAsync(x => x.id == id);
|
||||||
|
List<EqpSpotInsRecordD> eqpSpotInsRecordDs = await _repository.AsSugarClient().Queryable<EqpSpotInsRecordD>()
|
||||||
|
.Where(x => x.spot_ins_record_id == id).ToListAsync();
|
||||||
|
SpotInsRecordRepeatOutput output = new SpotInsRecordRepeatOutput()
|
||||||
|
{
|
||||||
|
model = eqpSpotInsRecordH,
|
||||||
|
details = eqpSpotInsRecordDs,
|
||||||
|
};
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 复核点巡检
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task RepeatSpotIns(SpotInsRecordRepeatInput input)
|
||||||
|
{
|
||||||
|
await _repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||||
|
{
|
||||||
|
repeat_result = input.repeat_result,
|
||||||
|
repeat_remark = input.repeat_remark,
|
||||||
|
repeat_post_info_user_id = _userManager.UserId,
|
||||||
|
repeat_time = DateTime.Now,
|
||||||
|
status = SpotInsRecordExecutionStatus.COMPLETED
|
||||||
|
}, x => x.id == input.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user