Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
16
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainInfoQueryinput.cs
Normal file
16
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainInfoQueryinput.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class MaintainInfoQueryinput
|
||||||
|
{
|
||||||
|
public string? sort { get; set; }
|
||||||
|
public string? keyword { get; set; }
|
||||||
|
|
||||||
|
public string? status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ namespace Tnb.EquipMgr.Entities.Dto
|
|||||||
/// 保养项Ids
|
/// 保养项Ids
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<MaintainItemInfo> items { get; set; }
|
public List<MaintainItemInfo> items { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string starttime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MaintainItemInfo
|
public class MaintainItemInfo
|
||||||
@@ -37,5 +40,7 @@ namespace Tnb.EquipMgr.Entities.Dto
|
|||||||
public string item_group_id { get; set; }
|
public string item_group_id { get; set; }
|
||||||
public string item_id { get; set; }
|
public string item_id { get; set; }
|
||||||
|
|
||||||
|
public string result { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,4 +47,6 @@ public partial class ToolMoldMaintainItemRecord : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string plan_id { get; set; }
|
public string plan_id { get; set; }
|
||||||
|
|
||||||
|
public string result { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reactive.Joins;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Aop.Api.Domain;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
|
using Aspose.Words;
|
||||||
using DingTalk.Api.Request;
|
using DingTalk.Api.Request;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
@@ -13,7 +16,10 @@ using JNPF.DependencyInjection;
|
|||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using JNPF.Systems.Entitys.System;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -64,35 +70,120 @@ namespace Tnb.EquipMgr
|
|||||||
plan_start_time = c.plan_start_time,
|
plan_start_time = c.plan_start_time,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (planMoldRelations?.Count > 0)
|
var moldids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||||
|
var molds = await _db.Queryable<ToolMolds>().Where(it => moldids.Contains(it.id)).ToListAsync();
|
||||||
|
foreach (var planMoldRelation in planMoldRelations)
|
||||||
|
|
||||||
{
|
{
|
||||||
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
var mold= molds.Where(p=>p.id== planMoldRelation.mold_id).FirstOrDefault();
|
||||||
var molds = await _db.Queryable<ToolMolds>().Where(it => mids.Contains(it.id)).ToListAsync();
|
if (mold != null)
|
||||||
if (molds?.Count > 0)
|
|
||||||
{
|
{
|
||||||
for (int i = 0, cnt = molds.Count; i < cnt; i++)
|
dynamic info = new ExpandoObject();
|
||||||
|
info.mold_id = mold.id;
|
||||||
|
info.mold_code = mold.mold_code;
|
||||||
|
info.mold_name = mold.mold_name;
|
||||||
|
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status!))?.FullName;
|
||||||
|
info.maintain_qty = mold.maintain_qty;
|
||||||
|
info.plan_start_time = planMoldRelation.plan_start_time == null ? "" : ((DateTime)planMoldRelation.plan_start_time).ToString("yyyy-MM-dd");
|
||||||
|
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
||||||
|
if (moldEqpRelation != null)
|
||||||
{
|
{
|
||||||
var mold = molds[i];
|
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
||||||
dynamic info = new ExpandoObject();
|
info.eqp_code = eqp.code;
|
||||||
info.mold_id = mold.id;
|
info.eqp_name = eqp.name;
|
||||||
info.mold_code = mold.mold_code;
|
|
||||||
info.mold_name = mold.mold_name;
|
|
||||||
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status))?.FullName;
|
|
||||||
info.maintain_qty = mold.maintain_qty;
|
|
||||||
info.plan_start_time = planMoldRelations[i].plan_start_time;
|
|
||||||
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
|
||||||
if (moldEqpRelation != null)
|
|
||||||
{
|
|
||||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
|
||||||
info.eqp_code = eqp.code;
|
|
||||||
info.eqp_name = eqp.name;
|
|
||||||
}
|
|
||||||
result.Add(info);
|
|
||||||
}
|
}
|
||||||
|
result.Add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<dynamic> GetMaintainInfo([FromQuery] MaintainInfoQueryinput input)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dicstatus = new Dictionary<string, string>();
|
||||||
|
dicstatus.Add("UnMaintain", "待保养");
|
||||||
|
dicstatus.Add("Completed", "已完成");
|
||||||
|
List<dynamic> result = new();
|
||||||
|
var plans = await _db.Queryable<ToolMoldMaintainPlan>().ToListAsync();
|
||||||
|
var ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
|
||||||
|
var ToolMoldsEquipments = await _db.Queryable<ToolMoldsEquipment>().ToListAsync();
|
||||||
|
var EqpEquipments = await _db.Queryable<EqpEquipment>().ToListAsync();
|
||||||
|
var dic = await _db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync();
|
||||||
|
var users = await _db.Queryable<UserEntity>().ToListAsync();
|
||||||
|
var records = _db.Queryable<ToolMoldMaintainItemRecord>().ToList();
|
||||||
|
var runrecords = _db.Queryable<ToolMoldMaintainRunRecord>().ToList();
|
||||||
|
foreach (var plan in plans)
|
||||||
|
{
|
||||||
|
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||||
|
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
|
||||||
|
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||||
|
.Where(a => a.maintain_plan_id == plan.id)
|
||||||
|
.Select((a, b, c) => new
|
||||||
|
{
|
||||||
|
mold_id = a.mold_id,
|
||||||
|
plan_start_time = c.plan_start_time,
|
||||||
|
}).ToListAsync();
|
||||||
|
if (planMoldRelations?.Count > 0)
|
||||||
|
{
|
||||||
|
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||||
|
var molds = ToolMolds.Where(it => mids.Contains(it.id))
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(input.keyword), p => p.mold_code!.Contains(input.keyword!) || p.mold_name!.Contains(input.keyword!))
|
||||||
|
.ToList();
|
||||||
|
if (molds?.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0, cnt = molds.Count; i < cnt; i++)
|
||||||
|
{
|
||||||
|
var mold = molds[i];
|
||||||
|
if (!string.IsNullOrEmpty(input.status))
|
||||||
|
{
|
||||||
|
var moldstatus = records.Where(p => p.mold_id == mold.id && p.plan_id == plan.id).Any() ? "已完成" : "待保养";
|
||||||
|
if (input.status != moldstatus)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dynamic info = new ExpandoObject();
|
||||||
|
info.mold_id = mold.id;
|
||||||
|
info.mold_code = mold.mold_code;
|
||||||
|
info.mold_name = mold.mold_name;
|
||||||
|
info.mold_status = dic.Where(p => p.Id == mold.mold_status).Any() ? dic.Where(p => p.Id == mold.mold_status).First().FullName : "";
|
||||||
|
info.maintain_qty = mold.maintain_qty;
|
||||||
|
info.plan_start_time = plan.plan_start_date == null ? "" : ((DateTime)plan.plan_start_date!).ToString("yyyy-MM-dd");
|
||||||
|
info.createtime = plan.create_time == null ? "" : ((DateTime)plan.create_time).ToString("yyyy-MM-dd");
|
||||||
|
info.status = records.Where(p=>p.mold_id== mold.id&&p.plan_id== plan.id).Any()? "已完成" : "待保养";//plan.status == "UnMaintain" ? "待保养" : "已完成";
|
||||||
|
info.createuser = string.IsNullOrEmpty(plan.create_id) ? "" : users.Where(p => p.Id == plan.create_id).First().RealName;
|
||||||
|
info.plan_id = plan.id;
|
||||||
|
info.starttime = "";
|
||||||
|
if (runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).Any())
|
||||||
|
{
|
||||||
|
var run = runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).First();
|
||||||
|
info.starttime = run.plan_start_time!=null? ((DateTime)run.plan_start_time).ToString("yyyy-MM-dd") : "";
|
||||||
|
}
|
||||||
|
var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
|
||||||
|
if (moldEqpRelation != null)
|
||||||
|
{
|
||||||
|
var eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault();
|
||||||
|
if (eqp != null)
|
||||||
|
{
|
||||||
|
info.eqp_code = eqp.code;
|
||||||
|
info.eqp_name = eqp.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Add(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(input.sort))
|
||||||
|
{
|
||||||
|
if (input.sort == "createtime")
|
||||||
|
result = result.OrderByDescending(p => p.createtime).ToList();
|
||||||
|
if (input.sort == "plan_start_time")
|
||||||
|
result = result.OrderByDescending(p => p.plan_start_time).ToList(); ;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据计划Id、模具ID获取,保养组及项目信息
|
/// 根据计划Id、模具ID获取,保养组及项目信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -175,6 +266,14 @@ namespace Tnb.EquipMgr
|
|||||||
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException("input");
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
|
var flag= _db.Queryable<ToolMoldMaintainRunRecord>()
|
||||||
|
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.plan_code == b.plan_code)
|
||||||
|
.LeftJoin<ToolMolds>((a,b,c)=>a.mold_code==c.mold_code)
|
||||||
|
.Where((a,b,c)=>b.id== input.plan_id&&c.id==input.mold_id).Any();
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
@@ -200,7 +299,7 @@ namespace Tnb.EquipMgr
|
|||||||
record.designer_time = DateTime.Now;
|
record.designer_time = DateTime.Now;
|
||||||
record.mold_code = mold.mold_code;
|
record.mold_code = mold.mold_code;
|
||||||
record.mold_name = mold.mold_name;
|
record.mold_name = mold.mold_name;
|
||||||
record.plan_start_time = DateTime.Now;
|
record.plan_start_time = string.IsNullOrEmpty(input.starttime) ? DateTime.Now :DateTime.Parse(input.starttime);
|
||||||
var row = await _db.Insertable(record).ExecuteCommandAsync();
|
var row = await _db.Insertable(record).ExecuteCommandAsync();
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
@@ -264,6 +363,37 @@ namespace Tnb.EquipMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养完成
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task FinishMaintain(MoldMaintainRunUpInput input)
|
||||||
|
{
|
||||||
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
|
if (input.items == null || input.items.Count == 0) throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
|
||||||
|
List<ToolMoldMaintainItemRecord> records = new();
|
||||||
|
foreach (var item in input.items)
|
||||||
|
{
|
||||||
|
ToolMoldMaintainItemRecord record = new();
|
||||||
|
record.plan_id = input.plan_id;
|
||||||
|
record.mold_id = input.mold_id;
|
||||||
|
record.item_group_id = item.item_group_id;
|
||||||
|
record.item_id = item.item_id;
|
||||||
|
record.status = 1;
|
||||||
|
record.result = item.result;
|
||||||
|
records.Add(record);
|
||||||
|
}
|
||||||
|
await _db.Insertable(records).ExecuteCommandAsync();
|
||||||
|
await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
|
||||||
|
var count = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(p => p.maintain_plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
|
||||||
|
var finish = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(p => p.plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
|
||||||
|
if (count == finish)
|
||||||
|
await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
|
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
|
||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException("input");
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class AndonRecordInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 关联工单
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 故障
|
||||||
|
/// </summary>
|
||||||
|
public string? breakdown { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class GanntSaveInput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string row_id { get; set; }
|
||||||
|
public GanntTime time { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GanntTime
|
||||||
|
{
|
||||||
|
public DateTime? start { get; set; }
|
||||||
|
public DateTime? end { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GanntTimeTips
|
||||||
|
{
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
public DateTime? start_time { get; set; }
|
||||||
|
public DateTime? end_time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities
|
||||||
|
{
|
||||||
|
[SugarTable("andon_breakdown")]
|
||||||
|
public partial class AndonBreakDown : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public AndonBreakDown()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
public string? name { get; set; }
|
||||||
|
public string? code { get; set; }
|
||||||
|
public string? description { get; set; }
|
||||||
|
|
||||||
|
public string? type_id { get; set; }
|
||||||
|
public string? remark { get; set; }
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities
|
||||||
|
{
|
||||||
|
[SugarTable("andon_records")]
|
||||||
|
public partial class AndonRecords : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public AndonRecords()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 关联工单
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 故障类别
|
||||||
|
/// </summary>
|
||||||
|
public string? breakdown_type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 故障
|
||||||
|
/// </summary>
|
||||||
|
public string? breakdown { get; set; }
|
||||||
|
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
public string? remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
15
ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs
Normal file
15
ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Interfaces
|
||||||
|
{
|
||||||
|
public interface IAndonService
|
||||||
|
{
|
||||||
|
Task<dynamic> GetPrdTask(string stationId);
|
||||||
|
Task SaveData(AndonRecordInput AndonRecordInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
ProductionMgr/Tnb.ProductionMgr/AndonService.cs
Normal file
87
ProductionMgr/Tnb.ProductionMgr/AndonService.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Reactive.Joins;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Aop.Api.Domain;
|
||||||
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Message.Service;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.TaskScheduler;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
using Tnb.ProductionMgr.Entities;
|
||||||
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
|
using Tnb.ProductionMgr.Entities.Entity;
|
||||||
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr
|
||||||
|
{
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
public class AndonService : IAndonService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
public AndonService(ISqlSugarRepository<AndonRecords> repository,IUserManager userManager)
|
||||||
|
{
|
||||||
|
_userManager = userManager;
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetPrdTask(string stationId)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||||
|
dic.Add("ToBeStarted", "待开工");
|
||||||
|
dic.Add("InProgress", "进行中");
|
||||||
|
dic.Add("Closed", "关闭");
|
||||||
|
dic.Add("Complated", "完工");
|
||||||
|
dic.Add("ToBeScheduled", "待下发");
|
||||||
|
dic.Add("Pause", "暂停");
|
||||||
|
dic.Add("Exception", "异常");
|
||||||
|
dic.Add("Revoke", "撤销");
|
||||||
|
List<dynamic> result = new();
|
||||||
|
var List = await _db.Queryable<PrdMoTask>()
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(stationId), p => p.workstation_id == stationId)
|
||||||
|
.ToListAsync();
|
||||||
|
var materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||||
|
foreach (var data in List)
|
||||||
|
{
|
||||||
|
dynamic info = new ExpandoObject();
|
||||||
|
info.id = data.id;
|
||||||
|
info.material_id = materials.Where(p => p.id == data.material_id).Any() ? materials.Where(p => p.id == data.material_id).First().name : "";
|
||||||
|
info.material_id_id = data.material_id;
|
||||||
|
info.status = dic.Where(p => p.Key == data.mo_task_status).Any() ? dic.Where(p => p.Key == data.mo_task_status).First().Value : "";
|
||||||
|
info.mo_code = data.mo_task_code;
|
||||||
|
info.mo_type = data.schedule_type == 1 ? "注塑工单" : "组装工单";
|
||||||
|
info.plan_gty = data.plan_qty;
|
||||||
|
info.plan_start_date = data.estimated_start_date == null ? "" : ((DateTime)data.estimated_start_date!).ToString("yyyy-MM-dd");
|
||||||
|
info.plan_end_date = data.estimated_end_date == null ? "" : ((DateTime)data.estimated_end_date!).ToString("yyyy-MM-dd");
|
||||||
|
result.Add(info);
|
||||||
|
}
|
||||||
|
result.OrderByDescending(p => p.plan_start_date);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public async Task SaveData(AndonRecordInput AndonRecordInput)
|
||||||
|
{
|
||||||
|
var list = _db.Queryable<AndonBreakDown>().ToList();
|
||||||
|
AndonRecords andonRecord = new AndonRecords();
|
||||||
|
andonRecord.mo_id = AndonRecordInput.mo_id;
|
||||||
|
andonRecord.breakdown_type = list.Where(p => p.id == AndonRecordInput.breakdown).Any() ? list.Where(p => p.id == AndonRecordInput.breakdown).First().type_id : "";
|
||||||
|
andonRecord.breakdown = AndonRecordInput.breakdown;
|
||||||
|
andonRecord.create_time = DateTime.Now;
|
||||||
|
andonRecord.create_id = _userManager.UserId;
|
||||||
|
await _db.Insertable(andonRecord).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -235,7 +235,7 @@ namespace Tnb.ProductionMgr
|
|||||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||||
|
|
||||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||||
.Where(x => x.carry_id == carry.id && x.is_all_feeding == 0).FirstAsync();
|
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||||
decimal num = Convert.ToDecimal(item["num"]);
|
decimal num = Convert.ToDecimal(item["num"]);
|
||||||
list.Add(new PrdFeedingD
|
list.Add(new PrdFeedingD
|
||||||
{
|
{
|
||||||
@@ -283,8 +283,8 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||||
// await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ using Tnb.EquipMgr.Entities;
|
|||||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
using JNPF.Common.Filter;
|
using JNPF.Common.Filter;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using JNPF.Systems.Interfaces.Permission;
|
||||||
|
using SQLitePCL;
|
||||||
|
using SqlSugar.Extensions;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -40,15 +44,18 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
private readonly ISqlSugarRepository<PrdInstockH> _repository;
|
private readonly ISqlSugarRepository<PrdInstockH> _repository;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IOrganizeService _organizeService;
|
||||||
private const string ModuleId = "25572529329173";
|
private const string ModuleId = "25572529329173";
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
public PrdInstockService(
|
public PrdInstockService(
|
||||||
ISqlSugarRepository<PrdInstockH> repository,
|
ISqlSugarRepository<PrdInstockH> repository,
|
||||||
|
IOrganizeService organizeService,
|
||||||
IUserManager userManager
|
IUserManager userManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
|
_organizeService = organizeService;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
OverideFuncs.GetListAsync = GetList;
|
OverideFuncs.GetListAsync = GetList;
|
||||||
}
|
}
|
||||||
@@ -100,8 +107,18 @@ namespace Tnb.ProductionMgr
|
|||||||
PrdInstockH prdInstockH = null;
|
PrdInstockH prdInstockH = null;
|
||||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||||
DbResult<bool> result2 = new DbResult<bool>();
|
DbResult<bool> result2 = new DbResult<bool>();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(input.station_id))
|
||||||
|
{
|
||||||
|
throw Oops.Bah("请先选择工位");
|
||||||
|
}
|
||||||
|
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode);
|
||||||
|
|
||||||
|
|
||||||
prdInstockH = new PrdInstockH()
|
prdInstockH = new PrdInstockH()
|
||||||
{
|
{
|
||||||
bill_type = input.bill_type,
|
bill_type = input.bill_type,
|
||||||
@@ -111,8 +128,8 @@ namespace Tnb.ProductionMgr
|
|||||||
carry_code = input.carry_code,
|
carry_code = input.carry_code,
|
||||||
is_check = input.is_check,
|
is_check = input.is_check,
|
||||||
station_id = input.station_id,
|
station_id = input.station_id,
|
||||||
workline_id = input.workline_id,
|
workline_id = workline?.Id ?? "",
|
||||||
workshop_id = input.workshop_id,
|
workshop_id = workshop?.Id ?? "",
|
||||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||||
warehouse_id = location?.wh_id,
|
warehouse_id = location?.wh_id,
|
||||||
status = 0,
|
status = 0,
|
||||||
@@ -127,8 +144,10 @@ namespace Tnb.ProductionMgr
|
|||||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
// code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
||||||
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
// barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
||||||
|
barcode = item.ContainsKey("barcode") ? item["barcode"] : "",
|
||||||
|
code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "",
|
||||||
quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -166,7 +185,7 @@ namespace Tnb.ProductionMgr
|
|||||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "",
|
||||||
pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -175,8 +194,10 @@ namespace Tnb.ProductionMgr
|
|||||||
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
|
||||||
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
|
||||||
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
|
||||||
code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
// code_batch = item.ContainsKey("batch") ? item["batch"] : "",
|
||||||
barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
// barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
|
||||||
|
barcode = item.ContainsKey("barcode") ? item["barcode"] : "",
|
||||||
|
code_batch = item.ContainsKey("barcode") ? item["barcode"]+"0001" : "",
|
||||||
codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -188,7 +209,7 @@ namespace Tnb.ProductionMgr
|
|||||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
|
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
|
||||||
Log.Information(sendResult);
|
Log.Information(sendResult);
|
||||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
if (authResponse.code != 200)
|
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
|
||||||
{
|
{
|
||||||
throw Oops.Bah(authResponse.msg);
|
throw Oops.Bah(authResponse.msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ using JNPF.Extras.CollectiveOAuth.Models;
|
|||||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using JNPF.Systems.Interfaces.Permission;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Entitys;
|
using JNPF.VisualDev.Entitys;
|
||||||
@@ -37,15 +39,21 @@ namespace Tnb.ProductionMgr
|
|||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
private readonly IVisualDevService _visualDevService;
|
private readonly IVisualDevService _visualDevService;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IOrganizeService _organizeService;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
public PrdKittingOutService(ISqlSugarRepository<PrdKittingOutH> repository, IRunService runService, IBillRullService billRullService,IUserManager userManager,IVisualDevService visualDevService)
|
public PrdKittingOutService(ISqlSugarRepository<PrdKittingOutH> repository, IRunService runService,
|
||||||
|
IBillRullService billRullService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IOrganizeService organizeService,
|
||||||
|
IVisualDevService visualDevService)
|
||||||
{
|
{
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
_organizeService = organizeService;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
// OverideFuncs.CreateAsync = Create;
|
// OverideFuncs.CreateAsync = Create;
|
||||||
}
|
}
|
||||||
@@ -161,6 +169,8 @@ namespace Tnb.ProductionMgr
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(kittingOutInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
kittingOutInput.workline_id = workline?.Id ?? "";
|
||||||
|
|
||||||
List<MESKittingOutStkInput> input = new List<MESKittingOutStkInput>();
|
List<MESKittingOutStkInput> input = new List<MESKittingOutStkInput>();
|
||||||
input.Add(new MESKittingOutStkInput()
|
input.Add(new MESKittingOutStkInput()
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ using JNPF.Extras.CollectiveOAuth.Models;
|
|||||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using JNPF.Systems.Interfaces.Permission;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -38,17 +40,20 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
|
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IOrganizeService _organizeService;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
|
|
||||||
|
|
||||||
public PrdMaterialReceiptService(
|
public PrdMaterialReceiptService(
|
||||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||||
IBillRullService billRullService,
|
IBillRullService billRullService,
|
||||||
|
IOrganizeService organizeService,
|
||||||
IUserManager userManager
|
IUserManager userManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
_organizeService = organizeService;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +153,9 @@ namespace Tnb.ProductionMgr
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
|
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
|
||||||
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode);
|
||||||
|
|
||||||
prdMaterialReceiptH = new PrdMaterialReceiptH()
|
prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||||
{
|
{
|
||||||
code = code,
|
code = code,
|
||||||
@@ -155,9 +163,9 @@ namespace Tnb.ProductionMgr
|
|||||||
mo_task_id = input.mo_task_id,
|
mo_task_id = input.mo_task_id,
|
||||||
process_id = input.process_id,
|
process_id = input.process_id,
|
||||||
equip_id = input.equip_id,
|
equip_id = input.equip_id,
|
||||||
workshop_id = input.workshop_id,
|
workshop_id = workshop?.Id ?? "",
|
||||||
carry_id = input.carry_id,
|
carry_id = input.carry_id,
|
||||||
workline_id = input.workline_id,
|
workline_id = workline?.Id ?? "",
|
||||||
carry_code = input.carry_code,
|
carry_code = input.carry_code,
|
||||||
remark = input.remark,
|
remark = input.remark,
|
||||||
mbom_process_id = input.mbom_process_id,
|
mbom_process_id = input.mbom_process_id,
|
||||||
@@ -186,9 +194,9 @@ namespace Tnb.ProductionMgr
|
|||||||
member_carry_id = item["member_carry_id"]?.ToString(),
|
member_carry_id = item["member_carry_id"]?.ToString(),
|
||||||
member_carry_code = item["member_carry_code"]?.ToString(),
|
member_carry_code = item["member_carry_code"]?.ToString(),
|
||||||
feeding_num = 0,
|
feeding_num = 0,
|
||||||
supplier_id = item["supplier_id"]?.ToString(),
|
supplier_id = item.ContainsKey("supplier_id") ? item["supplier_id"]?.ToString() : "",
|
||||||
instock_time = (DateTime)item["instock_time"],
|
instock_time = item.ContainsKey("instock_time") ? (DateTime)item["instock_time"] : DateTime.Now,
|
||||||
check_conclusion = item["check_conclusion"]?.ToString()
|
check_conclusion = item.ContainsKey("check_conclusion") ? item["check_conclusion"]?.ToString() : "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -888,8 +888,8 @@ namespace Tnb.ProductionMgr
|
|||||||
.Where((a, b) => a.barcode == barcode).SumAsync((a, b) => b.num);
|
.Where((a, b) => a.barcode == barcode).SumAsync((a, b) => b.num);
|
||||||
output.list[0].material_name = basMaterial.name;
|
output.list[0].material_name = basMaterial.name;
|
||||||
output.list[0].material_standard = basMaterial.material_standard;
|
output.list[0].material_standard = basMaterial.material_standard;
|
||||||
output.list[0].supplier_name = basSupplier.supplier_name;
|
output.list[0].supplier_name = basSupplier?.supplier_name ?? "";
|
||||||
output.list[0].unit_name = unit.FullName;
|
output.list[0].unit_name = unit?.FullName ?? "";
|
||||||
|
|
||||||
return output.list[0];
|
return output.list[0];
|
||||||
}
|
}
|
||||||
@@ -914,10 +914,10 @@ namespace Tnb.ProductionMgr
|
|||||||
.Where(a => a.barcode == barcode)
|
.Where(a => a.barcode == barcode)
|
||||||
.Select((a, b, c) => c.mo_task_id).ToListAsync();
|
.Select((a, b, c) => c.mo_task_id).ToListAsync();
|
||||||
|
|
||||||
return await _db.Queryable<PrdMoTask>()
|
var result = await _db.Queryable<PrdMoTask>()
|
||||||
.LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
.LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||||
.Where((a,b,c)=>ids.Contains(a.id))
|
.Where((a, b, c) => ids.Contains(a.id))
|
||||||
.Select((a, b, c) => new PrdMoReverseFromFeedingOutput
|
.Select((a, b, c) => new PrdMoReverseFromFeedingOutput
|
||||||
{
|
{
|
||||||
mo_task_id = a.id,
|
mo_task_id = a.id,
|
||||||
@@ -927,22 +927,28 @@ namespace Tnb.ProductionMgr
|
|||||||
material_name = c.name,
|
material_name = c.name,
|
||||||
material_standard = c.material_standard,
|
material_standard = c.material_standard,
|
||||||
children = SqlFunc.Subqueryable<PrdFeedingD>()
|
children = SqlFunc.Subqueryable<PrdFeedingD>()
|
||||||
.LeftJoin<PrdFeedingH>((x,y)=>x.feeding_id==y.id)
|
.LeftJoin<PrdFeedingH>((x, y) => x.feeding_id == y.id)
|
||||||
.LeftJoin<UserEntity>((x,y,z)=>y.create_id==z.Id)
|
.LeftJoin<UserEntity>((x, y, z) => y.create_id == z.Id)
|
||||||
.LeftJoin<OrganizeEntity>((x,y,z,org)=>y.station_id==org.Id)
|
.LeftJoin<OrganizeEntity>((x, y, z, org) => y.station_id == org.Id)
|
||||||
.LeftJoin<BasProcess>((x,y,z,org,process)=>y.process_id==process.id)
|
.LeftJoin<BasProcess>((x, y, z, org, process) => y.process_id == process.id)
|
||||||
.LeftJoin<PrdMaterialReceiptD>((x,y,z,org,process,mp)=>x.material_receipt_detail_id==mp.id)
|
.LeftJoin<PrdMaterialReceiptD>((x, y, z, org, process, mp) =>
|
||||||
.Where((x,y,z)=>y.mo_task_id==a.id).ToList((x,y,z,org,process,mp)=>new PrdMoReverseFromFeedingDetailOutput
|
x.material_receipt_detail_id == mp.id)
|
||||||
{
|
.Where((x, y, z) => y.mo_task_id == a.id).ToList((x, y, z, org, process, mp) =>
|
||||||
feeding_detail_id = x.id,
|
new PrdMoReverseFromFeedingDetailOutput
|
||||||
feeding_time = y.create_time==null ? "" : y.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
{
|
||||||
num = x.num,
|
feeding_detail_id = x.id,
|
||||||
check_conclusion = mp.check_conclusion,
|
feeding_time = y.create_time == null
|
||||||
feeding_name = z.RealName,
|
? ""
|
||||||
station_name = org.FullName,
|
: y.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
process_name = process.process_name
|
num = x.num,
|
||||||
}),
|
check_conclusion = mp.check_conclusion,
|
||||||
|
feeding_name = z.RealName,
|
||||||
|
station_name = org.FullName,
|
||||||
|
process_name = process.process_name
|
||||||
|
}),
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
return result;
|
||||||
|
// return PageResult<PrdMoReverseFromFeedingOutput>.SqlSugarPageResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2221,5 +2221,122 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取组装包装生产排产甘特图信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetGanntInfo2()
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
var listRows = await db.Queryable<OrganizeEntity>()
|
||||||
|
.Where(x => x.DeleteMark==null && (x.Category == DictConst.RegionCategoryWorklineCode || x.Category == DictConst.RegionCategoryWorkshopCode))
|
||||||
|
.OrderByDescending(x=>x.Category)
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
id = x.Id,
|
||||||
|
expanded = true,
|
||||||
|
label = x.FullName,
|
||||||
|
parentId = x.Category==DictConst.RegionCategoryWorklineCode ? x.ParentId : ""
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
DateTime startTime = Convert.ToDateTime(new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).AddDays(-15).ToString("yyyy-MM-dd 00:00:00"));
|
||||||
|
DateTime endTime = Convert.ToDateTime(new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).AddMonths(1).AddDays(-1).AddDays(15).ToString("yyyy-MM-dd 23:59:59"));
|
||||||
|
var charItems = await db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<DictionaryDataEntity>((a,b,c)=>c.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==c.EnCode)
|
||||||
|
.Where((a, b) => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.ToBeScheduledEncode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.InProgressEnCode)
|
||||||
|
.Where((a,b)=>a.schedule_type==2 && string.IsNullOrEmpty(a.parent_id))
|
||||||
|
.Where((a,b)=>a.estimated_start_date!=null && a.estimated_end_date!=null)
|
||||||
|
.Where((a,b)=>a.estimated_start_date>=startTime && a.estimated_end_date<=endTime)
|
||||||
|
.Select((a, b,c) => new
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
label = b.name,
|
||||||
|
material_name = b.name,
|
||||||
|
reported_work_qty = a.reported_work_qty==null ? 0 : a.reported_work_qty,
|
||||||
|
scheduled_qty = a.scheduled_qty,
|
||||||
|
mo_task_status = c.FullName,
|
||||||
|
// label = b.name +" " +(a.reported_work_qty==null?0:a.reported_work_qty)+"/"+a.scheduled_qty + " " +c.FullName,
|
||||||
|
rowId = a.workline_id,
|
||||||
|
time = new GanntTime
|
||||||
|
{
|
||||||
|
start = a.estimated_start_date,
|
||||||
|
end = a.estimated_end_date
|
||||||
|
},
|
||||||
|
//linkedWith = SqlFunc.Subqueryable<PrdMoTask>().Where(x=>a.schedule_type==2 && string.IsNullOrEmpty(a.parent_id) && a.workline_id==x.workline_id && (x.mo_task_status==DictConst.ToBeStartedEnCode || x.mo_task_status==DictConst.MoStatusPauseCode || x.mo_task_status==DictConst.ToBeScheduledEncode)).ToList(x=>x.id),
|
||||||
|
tips = new GanntTimeTips
|
||||||
|
{
|
||||||
|
// material_code = b.code,
|
||||||
|
// material_name = b.name,
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
// start_time = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
// end_time = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
start_time = a.estimated_start_date,
|
||||||
|
end_time = a.estimated_end_date,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
// DateTime min = (DateTime)charItems.Min(x => x.time.start);
|
||||||
|
TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks);
|
||||||
|
TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(startTime.ToString("yyyy-MM-dd")).Ticks);
|
||||||
|
TimeSpan ts3 = ts1.Subtract(ts2).Duration();
|
||||||
|
|
||||||
|
|
||||||
|
result.Add("listRows",listRows);
|
||||||
|
result.Add("charItems",charItems);
|
||||||
|
result.Add("startTime",startTime);
|
||||||
|
result.Add("endTime",endTime);
|
||||||
|
result.Add("totalDays",ts3.TotalDays);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存组装包装生产排产甘特图信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> SaveData2(List<GanntSaveInput> input)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
foreach (var item in input)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(await db.Queryable<OrganizeEntity>().Where(x=>x.Id==item.row_id && x.Category==DictConst.RegionCategoryWorkshopCode).AnyAsync())
|
||||||
|
throw Oops.Bah("不能排在车间上");
|
||||||
|
var prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == item.id);
|
||||||
|
if (prdMoTask.workline_id != item.row_id)
|
||||||
|
{
|
||||||
|
await db.Updateable<PrdMoTask>()
|
||||||
|
.SetColumns(x=>x.workline_id == item.row_id)
|
||||||
|
.Where(x=>x.id==item.id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prdMoTask.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm") != item.time.start.Value.ToString("yyyy-MM-dd HH:mm"))
|
||||||
|
{
|
||||||
|
await db.Updateable<PrdMoTask>()
|
||||||
|
.SetColumns(x=>x.estimated_start_date==item.time.start)
|
||||||
|
.Where(x=>x.id==item.id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prdMoTask.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm")!=item.time.end.Value.ToString("yyyy-MM-dd HH:mm"))
|
||||||
|
{
|
||||||
|
await db.Updateable<PrdMoTask>()
|
||||||
|
.SetColumns(x=>x.estimated_end_date==item.time.end)
|
||||||
|
.Where(x=>x.id==item.id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||||
|
|
||||||
|
return result.IsSuccess ? "排产成功" : result.ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ namespace Tnb.ProductionMgr
|
|||||||
BasLocation location = await db.Queryable<BasLocation>().SingleAsync(x => x.id == locationId);
|
BasLocation location = await db.Queryable<BasLocation>().SingleAsync(x => x.id == locationId);
|
||||||
|
|
||||||
input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : "";
|
input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : "";
|
||||||
input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now;
|
// input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now;
|
||||||
|
input.outstock.bill_date = DateTime.Now;
|
||||||
input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId;
|
input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId;
|
||||||
input.outstock.warehouse_id = visualDevModelDataCrInput.data.ContainsKey("warehouse_id") ? visualDevModelDataCrInput.data["warehouse_id"].ToString() : "";
|
input.outstock.warehouse_id = visualDevModelDataCrInput.data.ContainsKey("warehouse_id") ? visualDevModelDataCrInput.data["warehouse_id"].ToString() : "";
|
||||||
input.outstock.create_id = _userManager.UserId;
|
input.outstock.create_id = _userManager.UserId;
|
||||||
|
|||||||
43
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs
Normal file
43
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.QcMgr.Entities
|
||||||
|
{
|
||||||
|
// <summary>
|
||||||
|
/// 抽样检验程序样本量字码表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("qc_aql_sample_code")]
|
||||||
|
public partial class QcAqlSampleCode : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public QcAqlSampleCode()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 检验水平
|
||||||
|
/// </summary>
|
||||||
|
public string? checklevel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最小值
|
||||||
|
/// </summary>
|
||||||
|
public int? min { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最大值
|
||||||
|
/// </summary>
|
||||||
|
public int? max { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字码
|
||||||
|
/// </summary>
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
53
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs
Normal file
53
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.QcMgr.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// aql抽样方案
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("qc_aql_sample_plan")]
|
||||||
|
public partial class QcAqlSamplePlan : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public QcAqlSamplePlan()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 检验类型
|
||||||
|
/// </summary>
|
||||||
|
public string? checktype { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字码
|
||||||
|
/// </summary>
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 样本量
|
||||||
|
/// </summary>
|
||||||
|
public int? samplesize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// aql值
|
||||||
|
/// </summary>
|
||||||
|
public decimal? aqlvalue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接受
|
||||||
|
/// </summary>
|
||||||
|
public int? ac { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拒收
|
||||||
|
/// </summary>
|
||||||
|
public int? re { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ using JNPF.Common.Enums;
|
|||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Spire.Xls.Core;
|
using Spire.Xls.Core;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
@@ -377,5 +378,8 @@ namespace Tnb.QcMgr
|
|||||||
}
|
}
|
||||||
return floats.Average();
|
return floats.Average();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
|||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
using Spire.Pdf.Lists;
|
using Spire.Pdf.Lists;
|
||||||
using Aop.Api.Domain;
|
using Aop.Api.Domain;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr
|
namespace Tnb.WarehouseMgr
|
||||||
{
|
{
|
||||||
@@ -55,6 +59,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
|
if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var LCode = d["location_code"]?.ToString() ?? string.Empty;
|
var LCode = d["location_code"]?.ToString() ?? string.Empty;
|
||||||
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位编号不可为空", 500);
|
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位编号不可为空", 500);
|
||||||
var isType = d["is_type"]?.ToString() ?? string.Empty;
|
var isType = d["is_type"]?.ToString() ?? string.Empty;
|
||||||
@@ -79,36 +87,38 @@ namespace Tnb.WarehouseMgr
|
|||||||
locs.Add(loc);
|
locs.Add(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||||
var whDic = await _db.Queryable<BasWarehouse>().Where(it => whCodes.Contains(it.whcode)).ToDictionaryAsync(x => x.whcode, x => x.id);
|
var whDic = await _db.Queryable<BasWarehouse>().Where(it => whCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.whcode)).ToDictionaryAsync(x => x.whcode, x => x.id);
|
||||||
var rgDic = await _db.Queryable<BasRegion>().Where(it => rgCodes.Contains(it.region_code)).ToDictionaryAsync(x => x.region_code, x => x.id);
|
var rgDic = await _db.Queryable<BasRegion>().Where(it => rgCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.region_code)).ToDictionaryAsync(x => x.region_code, x => x.id);
|
||||||
|
var orgId = _userManager.User.OrganizeId;
|
||||||
locs.ForEach(x =>
|
var userId = _userManager.UserId;
|
||||||
|
foreach (var l in locs)
|
||||||
{
|
{
|
||||||
if (!carryStdDic.ContainsKey(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
|
if (!carryStdDic.ContainsKey(l.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的载具规格有误", 500);
|
||||||
if (!whDic.ContainsKey(x.wh_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的仓库有误", 500);
|
if (!whDic.ContainsKey(l.wh_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的仓库有误", 500);
|
||||||
if (!rgDic.ContainsKey(x.region_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的区域名称有误", 500);
|
if (!rgDic.ContainsKey(l.region_id)) throw new AppFriendlyException($"第{locs.IndexOf(l) + 1}个数据的区域名称有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
l.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
l.org_id = orgId;
|
||||||
x.location_name = x.location_code;
|
l.location_name = l.location_code;
|
||||||
x.is_lock = 0;
|
l.is_lock = 0;
|
||||||
x.carrystd_id = carryStdDic[x.carrystd_id]?.ToString()!;
|
l.carrystd_id = carryStdDic[l.carrystd_id]?.ToString()!;
|
||||||
x.wh_id = whDic[x.wh_id]?.ToString()!;
|
l.wh_id = whDic[l.wh_id]?.ToString()!;
|
||||||
x.region_id = rgDic[x.region_id]?.ToString();
|
l.region_id = rgDic[l.region_id]?.ToString();
|
||||||
x.create_id = _userManager.UserId;
|
l.create_id = userId;
|
||||||
x.modify_id = null;
|
l.modify_id = null;
|
||||||
x.modify_time = null;
|
l.modify_time = null;
|
||||||
x.is_mix = 1;
|
l.is_mix = 1;
|
||||||
x.is_use = "0";
|
l.is_use = "0";
|
||||||
});
|
}
|
||||||
|
|
||||||
if (locs.Count > 1000)
|
if (locs.Count > 1000)
|
||||||
{
|
{
|
||||||
await _db.Fastest<BasLocation>().BulkCopyAsync(locs);
|
row = await _db.Fastest<BasLocation>().BulkCopyAsync(locs);
|
||||||
}
|
}
|
||||||
else if (locs.Count > 400)
|
else if (locs.Count > 400)
|
||||||
{
|
{
|
||||||
_db.Utilities.PageEach(locs, 100, async pageList => {
|
_db.Utilities.PageEach(locs, 100, async pageList => {
|
||||||
await _db.Insertable(pageList).ExecuteCommandAsync();
|
row = await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -130,5 +140,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,20 @@ namespace Tnb.WarehouseMgr
|
|||||||
x.modify_id = null;
|
x.modify_id = null;
|
||||||
x.modify_time = null;
|
x.modify_time = null;
|
||||||
});
|
});
|
||||||
row = await _db.Insertable(carrys).ExecuteCommandAsync();
|
if (carrys.Count > 1000)
|
||||||
|
{
|
||||||
|
await _db.Fastest<WmsCarryH>().BulkCopyAsync(carrys);
|
||||||
|
}
|
||||||
|
else if (carrys.Count > 400)
|
||||||
|
{
|
||||||
|
_db.Utilities.PageEach(carrys, 100, async pageList => {
|
||||||
|
await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
row = await _db.Insertable(carrys).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ using JNPF.FriendlyException;
|
|||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
using NPOI.SS.Formula;
|
using NPOI.SS.Formula;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
@@ -39,6 +43,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
VisualDevImportDataOutput result = new VisualDevImportDataOutput();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
List<Dictionary<string, object>> dics = input.list;
|
List<Dictionary<string, object>> dics = input.list;
|
||||||
List<WmsPointH> points = new List<WmsPointH>();
|
List<WmsPointH> points = new List<WmsPointH>();
|
||||||
WmsPointH pt = new WmsPointH();
|
WmsPointH pt = new WmsPointH();
|
||||||
@@ -47,6 +52,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
|
if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
d.ContainsKey("location_code");
|
d.ContainsKey("location_code");
|
||||||
var pCode = d["point_code"]?.ToString() ?? string.Empty;
|
var pCode = d["point_code"]?.ToString() ?? string.Empty;
|
||||||
var pName = d["point_name"]?.ToString() ?? string.Empty;
|
var pName = d["point_name"]?.ToString() ?? string.Empty;
|
||||||
@@ -63,39 +72,41 @@ namespace Tnb.WarehouseMgr
|
|||||||
pt = d.Adapt<WmsPointH>();
|
pt = d.Adapt<WmsPointH>();
|
||||||
points.Add(pt);
|
points.Add(pt);
|
||||||
}
|
}
|
||||||
var aDic = await _db.Queryable<WmsAreaH>().Where(it => aCodes.Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
var aDic = await _db.Queryable<WmsAreaH>().Where(it => aCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id);
|
||||||
var lDic = await _db.Queryable<BasLocation>().Where(it => lCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
var lDic = await _db.Queryable<BasLocation>().Where(it => lCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||||
points.ForEach(x =>
|
var orgId = _userManager.User.OrganizeId;
|
||||||
|
var userId = _userManager.UserId;
|
||||||
|
foreach (var p in points)
|
||||||
{
|
{
|
||||||
if (!aDic.ContainsKey(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号有误", 500);
|
if (!aDic.ContainsKey(p.area_code)) throw new AppFriendlyException($"第{points.IndexOf(p) + 1}个数据的管理区编号有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
p.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
p.org_id = orgId;
|
||||||
x.is_lock = 0;
|
p.is_lock = 0;
|
||||||
x.status = 1;
|
p.status = 1;
|
||||||
x.point_x = 0;
|
p.point_x = 0;
|
||||||
x.point_y = 0;
|
p.point_y = 0;
|
||||||
x.point_z = 0;
|
p.point_z = 0;
|
||||||
x.location_id = x.location_code != null ? lDic[x.location_code]?.ToString() : null;
|
p.location_id = p.location_code != null && p.location_code != string.Empty ? lDic[p.location_code]?.ToString() : null;
|
||||||
x.area_id = aDic[x.area_code]?.ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号编号有误", 500);
|
p.area_id = aDic[p.area_code]?.ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(p) + 1}个数据的管理区编号编号有误", 500);
|
||||||
x.create_id = _userManager.UserId;
|
p.create_id = userId;
|
||||||
x.modify_id = null;
|
p.modify_id = null;
|
||||||
x.modify_time = null;
|
p.modify_time = null;
|
||||||
});
|
}
|
||||||
if (points.Count > 1000)
|
if (points.Count > 1000)
|
||||||
{
|
{
|
||||||
await _db.Fastest<WmsPointH>().BulkCopyAsync(points);
|
row = await _db.Fastest<WmsPointH>().BulkCopyAsync(points);
|
||||||
}
|
}
|
||||||
else if (points.Count > 400)
|
else if (points.Count > 400)
|
||||||
{
|
{
|
||||||
_db.Utilities.PageEach(points, 100, async pageList => {
|
_db.Utilities.PageEach(points, 100, async pageList =>
|
||||||
await _db.Insertable(pageList).ExecuteCommandAsync();
|
{
|
||||||
|
row = await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
row = await _db.Insertable(points).ExecuteCommandAsync();
|
row = await _db.Insertable(points).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
row = await _db.Insertable(points).ExecuteCommandAsync();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -110,5 +121,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ using JNPF.VisualDev.Interfaces;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
using NPOI.SS.Formula;
|
using NPOI.SS.Formula;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
using Tnb.WarehouseMgr.Interfaces;
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
@@ -81,10 +84,15 @@ namespace Tnb.WarehouseMgr
|
|||||||
//遍历字典,找出需要查询数据库拿的相关字段
|
//遍历字典,找出需要查询数据库拿的相关字段
|
||||||
foreach (var d in dics)
|
foreach (var d in dics)
|
||||||
{
|
{
|
||||||
|
if (d.Select(x => x.Value.ToString()).ToList().Find(v => v != "" && v != string.Empty && v != null) == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var sCode = d["startpoint_code"]?.ToString() ?? string.Empty;
|
var sCode = d["startpoint_code"]?.ToString() ?? string.Empty;
|
||||||
var eCode = d["endpoint_code"]?.ToString() ?? string.Empty;
|
var eCode = d["endpoint_code"]?.ToString() ?? string.Empty;
|
||||||
var dis = d["distance"]?.ToString() ?? string.Empty;
|
var dis = d["distance"]?.ToString() ?? string.Empty;
|
||||||
if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500);
|
if (sCode == eCode)
|
||||||
|
throw new AppFriendlyException("起始点位不能等于终止点位", 500);
|
||||||
if (dis.IsEmpty())
|
if (dis.IsEmpty())
|
||||||
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
|
||||||
pointCodes.Add(sCode);
|
pointCodes.Add(sCode);
|
||||||
@@ -94,32 +102,35 @@ namespace Tnb.WarehouseMgr
|
|||||||
road = d.Adapt<WmsRoad>();
|
road = d.Adapt<WmsRoad>();
|
||||||
roads.Add(road);
|
roads.Add(road);
|
||||||
}
|
}
|
||||||
var points = await _db.Queryable<WmsPointH>().Where(it => pointCodes.Contains(it.point_code)).ToDictionaryAsync(x => x.point_code, x => x.id);
|
var points = await _db.Queryable<WmsPointH>().Where(it => pointCodes.FindAll(x => x.ToString().IsNotEmptyOrNull() && x.ToString() != "").Contains(it.point_code)).ToDictionaryAsync(x => x.point_code, x => x.id);
|
||||||
if (!points.IsNullOrEmpty())
|
if (!points.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
roads.ForEach(x =>
|
var orgId = _userManager.User.OrganizeId;
|
||||||
|
var userId = _userManager.UserId;
|
||||||
|
foreach (var r in roads)
|
||||||
{
|
{
|
||||||
if (!points.ContainsKey(x.startpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500);
|
if (!points.ContainsKey(r.startpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(r) + 1}个数据的起始点位编号有误", 500);
|
||||||
if (!points.ContainsKey(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500);
|
if (!points.ContainsKey(r.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(r) + 1}个数据的终止点位编号有误", 500);
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
r.id = SnowflakeIdHelper.NextId();
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
r.org_id = orgId;
|
||||||
x.startpoint_id = points[x.startpoint_code]?.ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500);
|
r.startpoint_id = points[r.startpoint_code]?.ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(r) + 1}个数据的起始点位编号有误", 500);
|
||||||
x.endpoint_id = points[x.endpoint_code]?.ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500);
|
r.endpoint_id = points[r.endpoint_code]?.ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(r) + 1}个数据的终止点位编号有误", 500);
|
||||||
x.road_code = $"{x.startpoint_code}-{x.endpoint_code}";
|
r.road_code = $"{r.startpoint_code}-{r.endpoint_code}";
|
||||||
x.status = 1;
|
r.status = 1;
|
||||||
x.create_id = _userManager.UserId;
|
r.create_id = userId;
|
||||||
x.modify_id = null;
|
r.modify_id = null;
|
||||||
x.modify_time = null;
|
r.modify_time = null;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
if (roads.Count > 1000)
|
if (roads.Count > 1000)
|
||||||
{
|
{
|
||||||
await _db.Fastest<WmsRoad>().BulkCopyAsync(roads);
|
row = await _db.Fastest<WmsRoad>().BulkCopyAsync(roads);
|
||||||
}
|
}
|
||||||
else if (roads.Count > 400)
|
else if (roads.Count > 400)
|
||||||
{
|
{
|
||||||
_db.Utilities.PageEach(roads, 100, async pageList => {
|
_db.Utilities.PageEach(roads, 100, async pageList =>
|
||||||
await _db.Insertable(pageList).ExecuteCommandAsync();
|
{
|
||||||
|
row = await _db.Insertable(pageList).ExecuteCommandAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -141,5 +152,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ namespace JNPF.VisualDev
|
|||||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||||
if (overideSvc != null && overideSvc.OverideFuncs.ImportDataAsync != null)
|
if (overideSvc != null && overideSvc.OverideFuncs.ImportDataAsync != null)
|
||||||
{
|
{
|
||||||
await overideSvc.OverideFuncs.ImportDataAsync(list);
|
result = await overideSvc.OverideFuncs.ImportDataAsync(list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user