去除引用common.props
This commit is contained in:
@@ -9,6 +9,7 @@ using JNPF.FriendlyException;
|
||||
using JNPF.Message.Entitys.Entity;
|
||||
using JNPF.Message.Service;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Model;
|
||||
@@ -16,30 +17,27 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.BasicData.Entities;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Message.Entitys.Entity;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using MessageTemplateEntity = JNPF.Message.Entitys.Entity.MessageTemplateEntity;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class AndonRecordService: IAndonRecordService, IDynamicApiController, ITransient
|
||||
public class AndonRecordService : IAndonRecordService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private SendMessageService _sendMessageService;
|
||||
private readonly IBasPushRuleLogService _basPushRuleLogService;
|
||||
private readonly TimeTaskService _timeTaskService;
|
||||
|
||||
|
||||
public AndonRecordService(ISqlSugarRepository<AndonRecords> repository,
|
||||
SendMessageService sendMessageService,
|
||||
TimeTaskService timeTaskService,
|
||||
@@ -60,11 +58,11 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<AndonInfo>((a, b) => a.andon_info_id == b.id)
|
||||
.LeftJoin<UserEntity>((a, b, c) => a.repair_id == c.Id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d) => a.create_id == d.Id)
|
||||
.LeftJoin<DictionaryTypeEntity>((a,b,c,d,e)=>e.EnCode==DictConst.AndonStatus)
|
||||
.LeftJoin<DictionaryDataEntity>((a,b,c,d,e,f)=>a.status==f.EnCode && e.Id==f.DictionaryTypeId)
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b, c, d, e) => e.EnCode == DictConst.AndonStatus)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f) => a.status == f.EnCode && e.Id == f.DictionaryTypeId)
|
||||
.Where((a, b, c, d) => a.andon_type_id == input.andon_type_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.status),(a, b, c, d)=>a.status==input.status)
|
||||
.Select((a, b, c, d,e,f) => new AndonPadListOutput
|
||||
.WhereIF(!string.IsNullOrEmpty(input.status), (a, b, c, d) => a.status == input.status)
|
||||
.Select((a, b, c, d, e, f) => new AndonPadListOutput
|
||||
{
|
||||
id = a.id,
|
||||
andon_info_name = b.name,
|
||||
@@ -87,30 +85,30 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
AndonInfo andonInfo = await _db.Queryable<AndonInfo>().SingleAsync(x => x.id == input.andon_info_id);
|
||||
AndonRecords andonRecords = input.Adapt<AndonRecords>();
|
||||
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
|
||||
andonRecords.create_time = DateTime.Now;
|
||||
andonRecords.create_id = _userManager.UserId;
|
||||
andonRecords.status = DictConst.AndonStatusHJZ;
|
||||
|
||||
|
||||
|
||||
List<string> toUsers = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(andonInfo.personnel))
|
||||
{
|
||||
toUsers.AddRange(JsonConvert.DeserializeObject<List<string>>(andonInfo.personnel));
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(andonInfo.position))
|
||||
{
|
||||
|
||||
|
||||
toUsers.AddRange(_db.Queryable<UserRelationEntity>().Where(x => andonInfo.position.Contains(x.Id)).Select(s => s.UserId).ToList());
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(andonInfo.role))
|
||||
{
|
||||
|
||||
|
||||
toUsers.AddRange(_db.Queryable<UserRelationEntity>().Where(x => andonInfo.role.Contains(x.Id)).Select(s => s.UserId).ToList());
|
||||
}
|
||||
|
||||
@@ -132,76 +130,76 @@ namespace Tnb.ProductionMgr
|
||||
await _db.Insertable<AndonRecords>(andonRecords).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
BasPushRuleH basPushRuleH = await _db.Queryable<BasPushRuleH>().SingleAsync(x => x.id == andonInfo.push_rule_id);
|
||||
BasPushRuleD basPushRuleD = await _db.Queryable<BasPushRuleD>().FirstAsync(x => x.push_rule_id == andonInfo.push_rule_id && x.ordinal == 1);
|
||||
if (basPushRuleH?.enabled == 1)
|
||||
{
|
||||
BasPushRuleH basPushRuleH = await _db.Queryable<BasPushRuleH>().SingleAsync(x=>x.id==andonInfo.push_rule_id);
|
||||
BasPushRuleD basPushRuleD = await _db.Queryable<BasPushRuleD>().FirstAsync(x => x.push_rule_id == andonInfo.push_rule_id && x.ordinal == 1);
|
||||
if (basPushRuleH?.enabled == 1)
|
||||
string sendConfigId = basPushRuleD?.send_config_id ?? "";
|
||||
List<MessageSendModel> sendModels = await GetSendParamJson(sendConfigId);
|
||||
|
||||
if (sendModels != null && sendModels.Count > 0)
|
||||
{
|
||||
string sendConfigId = basPushRuleD?.send_config_id ?? "";
|
||||
List<MessageSendModel> sendModels = await GetSendParamJson(sendConfigId);
|
||||
|
||||
if (sendModels != null && sendModels.Count > 0)
|
||||
DateTime executeTime = DateTime.Now.AddMinutes(basPushRuleD.interval);
|
||||
// string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ? {executeTime.Year}";
|
||||
string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ?";
|
||||
|
||||
var comtentModel = new ContentModel();
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
comtentModel.cron = cron;
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.localHostTaskId = "PushMsgTimeWorker/PushMsg";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
comtentModel.TenantId = _userManager?.TenantId;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig;
|
||||
comtentModel.Token = _userManager?.ToKen;
|
||||
|
||||
// foreach (var item in sendModels)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
|
||||
{
|
||||
DateTime executeTime = DateTime.Now.AddMinutes(basPushRuleD.interval);
|
||||
// string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ? {executeTime.Year}";
|
||||
string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ?";
|
||||
|
||||
var comtentModel = new ContentModel();
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
comtentModel.cron = cron;
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.localHostTaskId = "PushMsgTimeWorker/PushMsg";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
comtentModel.TenantId = _userManager?.TenantId;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig;
|
||||
comtentModel.Token = _userManager?.ToKen;
|
||||
|
||||
// foreach (var item in sendModels)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
|
||||
{
|
||||
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
fullName = "andon推送消息" + DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
executeType = "3",
|
||||
executeContent = comtentModel.ToJsonString(),
|
||||
description = JsonConvert.SerializeObject(sendModels[0].paramJson),
|
||||
sortCode = 9999,
|
||||
enabledMark = 1,
|
||||
};
|
||||
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
fullName = "andon推送消息" + DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
executeType = "3",
|
||||
executeContent = comtentModel.ToJsonString(),
|
||||
description = JsonConvert.SerializeObject(sendModels[0].paramJson),
|
||||
sortCode = 9999,
|
||||
enabledMark = 1,
|
||||
};
|
||||
|
||||
await _timeTaskService.Create(timeTaskCrInput,false);
|
||||
await _timeTaskService.Create(timeTaskCrInput, false);
|
||||
|
||||
TimeTaskEntity timeTaskEntity = await _db.Queryable<TimeTaskEntity>().Where(x => x.EnCode == timeTaskCrInput.enCode).FirstAsync();
|
||||
|
||||
BasPushRuleLog basPushRuleLog = new BasPushRuleLog()
|
||||
{
|
||||
push_rule_id = andonInfo.push_rule_id,
|
||||
timetask_id = timeTaskEntity?.Id,
|
||||
biz_id = andonRecords.id,
|
||||
ordinal = 1,
|
||||
is_push = 1,
|
||||
};
|
||||
TimeTaskEntity timeTaskEntity = await _db.Queryable<TimeTaskEntity>().Where(x => x.EnCode == timeTaskCrInput.enCode).FirstAsync();
|
||||
|
||||
await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
}
|
||||
BasPushRuleLog basPushRuleLog = new BasPushRuleLog()
|
||||
{
|
||||
push_rule_id = andonInfo.push_rule_id,
|
||||
timetask_id = timeTaskEntity?.Id,
|
||||
biz_id = andonRecords.id,
|
||||
ordinal = 1,
|
||||
is_push = 1,
|
||||
};
|
||||
|
||||
await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "发起成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ResponseAndon(Dictionary<string,string> dic)
|
||||
public async Task<dynamic> ResponseAndon(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
||||
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
||||
@@ -216,13 +214,13 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (andonRecords.status != DictConst.AndonStatusHJZ)
|
||||
{
|
||||
throw Oops.Bah($"状态错误");
|
||||
throw Oops.Bah($"状态错误");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x => x.repair_id == _userManager.UserId)
|
||||
.SetColumns(x=>x.response_time==DateTime.Now)
|
||||
.SetColumns(x => x.response_time == DateTime.Now)
|
||||
.ExecuteCommandAsync();
|
||||
Dictionary<string, string> postData = new Dictionary<string, string>()
|
||||
{
|
||||
@@ -231,13 +229,13 @@ namespace Tnb.ProductionMgr
|
||||
await _basPushRuleLogService.Stop(postData);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,21 +248,21 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (andonRecords.status != DictConst.AndonStatusYXY)
|
||||
{
|
||||
throw Oops.Bah($"状态错误");
|
||||
throw Oops.Bah($"状态错误");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x=>x.start_repair_time==DateTime.Now)
|
||||
.Where(x=>x.id==id)
|
||||
.SetColumns(x => x.start_repair_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,24 +275,24 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (andonRecords.status != DictConst.AndonStatusCLZ)
|
||||
{
|
||||
throw Oops.Bah($"状态错误");
|
||||
throw Oops.Bah($"状态错误");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x=>x.end_repair_time==DateTime.Now)
|
||||
.Where(x=>x.id==id)
|
||||
.SetColumns(x => x.end_repair_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ConfirmAndon(Dictionary<string, string> dic)
|
||||
{
|
||||
@@ -304,21 +302,21 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (andonRecords.status != DictConst.AndonStatusYWC)
|
||||
{
|
||||
throw Oops.Bah($"状态错误");
|
||||
throw Oops.Bah($"状态错误");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x=>x.confirm_time==DateTime.Now)
|
||||
.Where(x=>x.id==id)
|
||||
.SetColumns(x => x.confirm_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
throw Oops.Bah($"无该andon记录");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user