合并
This commit is contained in:
@@ -84,25 +84,47 @@ namespace Tnb.BasicData
|
||||
public async Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
||||
BasEbomH ebom = await db.Queryable<BasEbomH>().Where(x => x.id == queryInput.ebom_id).SingleAsync();
|
||||
ids.Add(ebom.material_id);
|
||||
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))
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
|
||||
.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);
|
||||
if (!string.IsNullOrEmpty(queryInput.ebom_id))
|
||||
{
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
||||
BasEbomH ebom = await db.Queryable<BasEbomH>().Where(x => x.id == queryInput.ebom_id).SingleAsync();
|
||||
ids.Add(ebom.material_id);
|
||||
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))
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
|
||||
.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);
|
||||
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>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
@@ -9,6 +10,21 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="pageInput"></param>
|
||||
/// <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;
|
||||
|
||||
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模板id发布到设备
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
[HttpPost]
|
||||
public async Task<string> Publish(SpotInsTemPublishInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -47,7 +51,7 @@ namespace Tnb.EquipMgr
|
||||
foreach (var equipId in input.equipIds)
|
||||
{
|
||||
string id = SnowflakeIdHelper.NextId();
|
||||
string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}";
|
||||
string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
|
||||
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
|
||||
{
|
||||
id = id,
|
||||
@@ -82,12 +86,17 @@ namespace Tnb.EquipMgr
|
||||
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
spot_ins_item_id = eqpSpotInsTem.id,
|
||||
spot_ins_item_id = eqpSpotInsTem.spot_ins_item_id,
|
||||
spot_ins_tem_equip_id = id,
|
||||
};
|
||||
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)
|
||||
|
||||
@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
@@ -39,24 +40,20 @@ namespace Tnb.EquipMgr
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_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 () =>
|
||||
{
|
||||
//string attachment = JsonConvert.SerializeObject(input.data["attachment"]);
|
||||
// _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());
|
||||
EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.id);
|
||||
string status = "";
|
||||
if (eqpSpotInsRecordH.is_repeat == "1")
|
||||
{
|
||||
@@ -66,17 +63,68 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED;
|
||||
}
|
||||
_repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||
{
|
||||
status = status,
|
||||
spot_record_date_time = DateTime.Now,
|
||||
spot_record_user_id = _userManager.UserId
|
||||
}, x => x.id == input.data["id"]);
|
||||
await _repository.UpdateAsync(x => new EqpSpotInsRecordH()
|
||||
{
|
||||
result = input.result,
|
||||
attachment = input.attachment,
|
||||
result_remark = input.result_remark,
|
||||
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);
|
||||
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