2024-09-18 10:48:34 +08:00
|
|
|
|
using FineUIPro;
|
|
|
|
|
|
using Model;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 入库单逻辑层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class TwOutputmasterService
|
2025-10-10 14:33:21 +08:00
|
|
|
|
{
|
2024-09-18 10:48:34 +08:00
|
|
|
|
#region 获取列表
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 记录数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static int Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
set;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static IQueryable<Model.Tw_InOutMasterOutput> GetModle(Model.Tw_InOutMasterOutput table)
|
|
|
|
|
|
{
|
|
|
|
|
|
var q = from x in Funs.DB.Tw_OutputMaster
|
2025-10-10 14:33:21 +08:00
|
|
|
|
join y in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals y.Id into yy
|
|
|
|
|
|
from y in yy.DefaultIfEmpty()
|
|
|
|
|
|
//join z in Funs.DB.HJGL_WeldTask on y.WeldTaskId equals z.WeldTaskId into zz
|
|
|
|
|
|
//from z in zz.DefaultIfEmpty()
|
2024-09-18 10:48:34 +08:00
|
|
|
|
join person in Funs.DB.Person_Persons on x.CreateMan equals person.PersonId into persons
|
2025-10-10 14:33:21 +08:00
|
|
|
|
from person in persons.DefaultIfEmpty()
|
2024-09-24 20:38:50 +08:00
|
|
|
|
join auditperson in Funs.DB.Person_Persons on x.AuditMan equals auditperson.PersonId into auditpersons
|
|
|
|
|
|
from auditperson in auditpersons.DefaultIfEmpty()
|
2024-12-06 22:17:50 +08:00
|
|
|
|
join auditperson2 in Funs.DB.Person_Persons on x.AuditMan2 equals auditperson2.PersonId into auditpersons2
|
|
|
|
|
|
from auditperson2 in auditpersons2.DefaultIfEmpty()
|
2024-11-07 16:22:03 +08:00
|
|
|
|
join warehouseperson in Funs.DB.Person_Persons on x.WarehouseMan equals warehouseperson.PersonId into warehousepersons
|
|
|
|
|
|
from warehouseperson in warehousepersons.DefaultIfEmpty()
|
2024-09-24 20:38:50 +08:00
|
|
|
|
join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units
|
2025-10-10 14:33:21 +08:00
|
|
|
|
from unit in units.DefaultIfEmpty()
|
|
|
|
|
|
where
|
|
|
|
|
|
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.CusBillCode) || x.CusBillCode.Contains(table.CusBillCode)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.CreateMan) || x.CreateMan.Contains(table.CreateMan)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.ReqUnitId) || x.ReqUnitId.Contains(table.ReqUnitId)) &&
|
|
|
|
|
|
(string.IsNullOrEmpty(table.UnitWorkId) || y.WeldTaskId.Contains(table.UnitWorkId)) &&
|
|
|
|
|
|
(table.TypeInt == null || x.TypeInt == table.TypeInt) &&
|
|
|
|
|
|
(table.Category == null || x.Category == table.Category) &&
|
|
|
|
|
|
(table.State == null || x.State == table.State)
|
|
|
|
|
|
orderby x.CreateDate descending
|
|
|
|
|
|
select new Model.Tw_InOutMasterOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
|
CusBillCode = x.CusBillCode,
|
|
|
|
|
|
InOutPlanMasterId = x.InOutPlanMasterId,
|
|
|
|
|
|
WarehouseCode = x.WarehouseCode,
|
|
|
|
|
|
Category = x.Category,
|
|
|
|
|
|
Source = x.Source,
|
|
|
|
|
|
TypeInt = x.TypeInt,
|
|
|
|
|
|
State = x.State,
|
|
|
|
|
|
CreateMan = x.CreateMan,
|
|
|
|
|
|
CreateManName = person.PersonName,
|
|
|
|
|
|
CreateDate = x.CreateDate,
|
|
|
|
|
|
ReqUnitId = x.ReqUnitId,
|
|
|
|
|
|
ReqUnitName = unit.UnitName,
|
|
|
|
|
|
WeldTaskId = y.WeldTaskId,
|
|
|
|
|
|
AuditMan = x.AuditMan,
|
|
|
|
|
|
AuditManName = auditperson.PersonName,
|
|
|
|
|
|
AuditDate = x.AuditDate,
|
|
|
|
|
|
AuditMan2 = x.AuditMan2,
|
|
|
|
|
|
AuditManName2 = auditperson2.PersonName,
|
|
|
|
|
|
AuditDate2 = x.AuditDate2,
|
|
|
|
|
|
WarehouseMan = x.WarehouseMan,
|
|
|
|
|
|
WarehouseDate = x.WarehouseDate,
|
|
|
|
|
|
WarehouseManName = warehouseperson.PersonName,
|
|
|
|
|
|
Remark = y.Remark
|
|
|
|
|
|
};
|
2024-09-18 10:48:34 +08:00
|
|
|
|
|
|
|
|
|
|
return q;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取分页列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table"></param>
|
|
|
|
|
|
/// <param name="grid1"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IEnumerable GetListData(Model.Tw_InOutMasterOutput table, Grid grid1)
|
|
|
|
|
|
{
|
|
|
|
|
|
var q = GetModle(table);
|
|
|
|
|
|
Count = q.Count();
|
|
|
|
|
|
if (Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
|
|
|
|
|
return from x in result
|
2025-10-10 14:33:21 +08:00
|
|
|
|
select new Model.Tw_InOutMasterOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
|
CusBillCode = x.CusBillCode,
|
|
|
|
|
|
WarehouseCode = x.WarehouseCode,
|
|
|
|
|
|
InOutPlanMasterId = x.InOutPlanMasterId,
|
|
|
|
|
|
Source = x.Source,
|
|
|
|
|
|
TypeInt = x.TypeInt,
|
|
|
|
|
|
State = x.State,
|
|
|
|
|
|
Category = x.Category,
|
|
|
|
|
|
CreateMan = x.CreateMan,
|
|
|
|
|
|
CreateManName = x.CreateManName,
|
|
|
|
|
|
CreateDate = x.CreateDate,
|
|
|
|
|
|
ReqUnitId = x.ReqUnitId,
|
|
|
|
|
|
ReqUnitName = x.ReqUnitName,
|
|
|
|
|
|
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
|
|
|
|
|
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key,
|
|
|
|
|
|
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
|
|
|
|
|
WeldTaskId = x.WeldTaskId,
|
|
|
|
|
|
WeldTaskCode = x.WeldTaskId != null ? x.WeldTaskId.Contains('|') ? Funs.DB.HJGL_WeldTask.FirstOrDefault(e => e.UnitWorkId == x.WeldTaskId.Split('|')[0].ToString() && e.UnitId == x.WeldTaskId.Split('|')[1].ToString() && e.TaskDate.Value.Date == DateTime.ParseExact(x.WeldTaskId.Split('|')[2].ToString(), "yyyyMMdd", null).Date)?.TaskCode : "" : "",
|
|
|
|
|
|
UnitWorkId = x.WeldTaskId != null ? x.WeldTaskId.Split('|')[0].ToString() : null,
|
|
|
|
|
|
AuditMan = x.AuditMan,
|
|
|
|
|
|
AuditManName = x.AuditManName,
|
|
|
|
|
|
AuditDate = x.AuditDate,
|
|
|
|
|
|
AuditMan2 = x.AuditMan2,
|
|
|
|
|
|
AuditManName2 = x.AuditManName2,
|
|
|
|
|
|
AuditDate2 = x.AuditDate2,
|
|
|
|
|
|
WarehouseMan = x.WarehouseMan,
|
|
|
|
|
|
WarehouseManName = x.WarehouseManName,
|
2026-04-16 20:30:48 +08:00
|
|
|
|
WarehouseDate = x.WarehouseDate,
|
|
|
|
|
|
Remark=x.Remark
|
2024-09-18 10:48:34 +08:00
|
|
|
|
|
2025-10-10 14:33:21 +08:00
|
|
|
|
};
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Tw_InOutMasterOutput> GetListData(Model.Tw_InOutMasterOutput table)
|
|
|
|
|
|
{
|
|
|
|
|
|
var q = GetModle(table);
|
|
|
|
|
|
Count = q.Count();
|
|
|
|
|
|
if (Count == 0)
|
|
|
|
|
|
{
|
2025-09-24 17:31:28 +08:00
|
|
|
|
return new List<Tw_InOutMasterOutput>();
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
var result = q.ToList();
|
|
|
|
|
|
return (from x in result
|
2025-10-10 14:33:21 +08:00
|
|
|
|
select new Model.Tw_InOutMasterOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
|
CusBillCode = x.CusBillCode,
|
|
|
|
|
|
InOutPlanMasterId = x.InOutPlanMasterId,
|
|
|
|
|
|
WarehouseCode = x.WarehouseCode,
|
|
|
|
|
|
Source = x.Source,
|
|
|
|
|
|
TypeInt = x.TypeInt,
|
|
|
|
|
|
State = x.State,
|
|
|
|
|
|
Category = x.Category,
|
|
|
|
|
|
CreateMan = x.CreateMan,
|
|
|
|
|
|
CreateManName = x.CreateManName,
|
|
|
|
|
|
CreateDate = x.CreateDate,
|
|
|
|
|
|
ReqUnitId = x.ReqUnitId,
|
|
|
|
|
|
ReqUnitName = x.ReqUnitName,
|
|
|
|
|
|
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
|
|
|
|
|
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key,
|
|
|
|
|
|
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
|
|
|
|
|
WeldTaskId = x.WeldTaskId,
|
|
|
|
|
|
WeldTaskCode = x.WeldTaskId != null ? x.WeldTaskId.Contains('|') ? Funs.DB.HJGL_WeldTask.FirstOrDefault(e => e.UnitWorkId == x.WeldTaskId.Split('|')[0].ToString() && e.UnitId == x.WeldTaskId.Split('|')[1].ToString() && e.TaskDate.Value.Date == DateTime.ParseExact(x.WeldTaskId.Split('|')[2].ToString(), "yyyyMMdd", null).Date)?.TaskCode : "" : "",
|
|
|
|
|
|
UnitWorkId = x.WeldTaskId != null ? x.WeldTaskId.Split('|')[0].ToString() : null,
|
|
|
|
|
|
AuditMan = x.AuditMan,
|
|
|
|
|
|
AuditManName = x.AuditManName,
|
|
|
|
|
|
AuditDate = x.AuditDate,
|
|
|
|
|
|
AuditMan2 = x.AuditMan2,
|
|
|
|
|
|
AuditManName2 = x.AuditManName2,
|
|
|
|
|
|
AuditDate2 = x.AuditDate2,
|
|
|
|
|
|
WarehouseMan = x.WarehouseMan,
|
|
|
|
|
|
WarehouseManName = x.WarehouseManName,
|
|
|
|
|
|
WarehouseDate = x.WarehouseDate
|
2024-09-18 10:48:34 +08:00
|
|
|
|
|
2025-10-10 14:33:21 +08:00
|
|
|
|
}).ToList();
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public static Model.Tw_OutputMaster GetTw_OutputMasterById(string Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Funs.DB.Tw_OutputMaster.FirstOrDefault(x => x.Id == Id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Add(Model.Tw_OutputMaster newtable)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Model.Tw_OutputMaster table = new Model.Tw_OutputMaster
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = newtable.Id,
|
|
|
|
|
|
ProjectId = newtable.ProjectId,
|
|
|
|
|
|
InOutPlanMasterId = newtable.InOutPlanMasterId,
|
|
|
|
|
|
CusBillCode = newtable.CusBillCode,
|
|
|
|
|
|
WarehouseCode = newtable.WarehouseCode,
|
|
|
|
|
|
Category = newtable.Category,
|
|
|
|
|
|
Source = newtable.Source,
|
|
|
|
|
|
TypeInt = newtable.TypeInt,
|
|
|
|
|
|
State = newtable.State,
|
|
|
|
|
|
CreateMan = newtable.CreateMan,
|
|
|
|
|
|
CreateDate = newtable.CreateDate,
|
2025-10-10 14:33:21 +08:00
|
|
|
|
ReqUnitId = newtable.ReqUnitId,
|
2024-09-24 20:38:50 +08:00
|
|
|
|
AuditMan = newtable.AuditMan,
|
2024-11-07 16:22:03 +08:00
|
|
|
|
AuditDate = newtable.AuditDate,
|
2024-12-06 22:17:50 +08:00
|
|
|
|
AuditMan2 = newtable.AuditMan2,
|
|
|
|
|
|
AuditDate2 = newtable.AuditDate2,
|
2024-11-07 16:22:03 +08:00
|
|
|
|
WarehouseMan = newtable.WarehouseMan,
|
|
|
|
|
|
WarehouseDate = newtable.WarehouseDate,
|
2024-09-18 10:48:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
Funs.DB.Tw_OutputMaster.InsertOnSubmit(table);
|
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Update(Model.Tw_OutputMaster newtable)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Model.Tw_OutputMaster table = Funs.DB.Tw_OutputMaster.FirstOrDefault(x => x.Id == newtable.Id);
|
|
|
|
|
|
if (table != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Id = newtable.Id;
|
|
|
|
|
|
table.ProjectId = newtable.ProjectId;
|
|
|
|
|
|
table.InOutPlanMasterId = newtable.InOutPlanMasterId;
|
|
|
|
|
|
table.CusBillCode = newtable.CusBillCode;
|
|
|
|
|
|
table.WarehouseCode = newtable.WarehouseCode;
|
|
|
|
|
|
table.Category = newtable.Category;
|
|
|
|
|
|
table.Source = newtable.Source;
|
|
|
|
|
|
table.TypeInt = newtable.TypeInt;
|
|
|
|
|
|
table.State = newtable.State;
|
|
|
|
|
|
table.CreateMan = newtable.CreateMan;
|
|
|
|
|
|
table.CreateDate = newtable.CreateDate;
|
|
|
|
|
|
table.ReqUnitId = newtable.ReqUnitId;
|
2024-09-24 20:38:50 +08:00
|
|
|
|
table.AuditMan = newtable.AuditMan;
|
|
|
|
|
|
table.AuditDate = newtable.AuditDate;
|
2024-12-06 22:17:50 +08:00
|
|
|
|
table.AuditMan2 = newtable.AuditMan2;
|
|
|
|
|
|
table.AuditDate2 = newtable.AuditDate2;
|
2024-11-07 16:22:03 +08:00
|
|
|
|
table.WarehouseMan = newtable.WarehouseMan;
|
|
|
|
|
|
table.WarehouseDate = newtable.WarehouseDate;
|
2024-09-18 10:48:34 +08:00
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void DeleteById(string Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Model.Tw_OutputMaster table = Funs.DB.Tw_OutputMaster.FirstOrDefault(x => x.Id == Id);
|
|
|
|
|
|
if (table != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Funs.DB.Tw_OutputMaster.DeleteOnSubmit(table);
|
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据计划单生成出库单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void GenOutMasterByPlanId(string planId, List<Model.Tw_OutputDetail> detailLists)
|
|
|
|
|
|
{
|
|
|
|
|
|
//获取出库单
|
|
|
|
|
|
var planQueryModel = new Tw_InOutMasterOutput();
|
2025-10-10 14:33:21 +08:00
|
|
|
|
planQueryModel.Id = planId;
|
|
|
|
|
|
var plan = TwInOutplanmasterService.GetListData(planQueryModel).FirstOrDefault();
|
|
|
|
|
|
if (plan == null || plan.State != (int)TwConst.State.已审核)
|
2024-09-18 10:48:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
//判断是否已经生成过出库单
|
|
|
|
|
|
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
|
|
|
|
|
queryIsExitInMaster.InOutPlanMasterId = planId;
|
2025-10-10 14:33:21 +08:00
|
|
|
|
queryIsExitInMaster.TypeInt = plan.TypeInt;
|
2024-09-18 10:48:34 +08:00
|
|
|
|
var IsExitInMaster = GetModle(queryIsExitInMaster).FirstOrDefault();
|
|
|
|
|
|
if (IsExitInMaster != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
2025-10-10 14:33:21 +08:00
|
|
|
|
}
|
2024-09-18 10:48:34 +08:00
|
|
|
|
//生成出库单
|
|
|
|
|
|
var master = new Model.Tw_OutputMaster()
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = Guid.NewGuid().ToString(),
|
|
|
|
|
|
InOutPlanMasterId = plan.Id,
|
|
|
|
|
|
ProjectId = plan.ProjectId,
|
2025-10-10 14:33:21 +08:00
|
|
|
|
CusBillCode = GetCusBillCode(plan.WeldTaskCode, (TwConst.TypeInt)plan.TypeInt, (BLL.TwConst.Category)plan.Category, plan.CusBillCode),
|
2024-09-18 10:48:34 +08:00
|
|
|
|
WarehouseCode = plan.WarehouseCode,
|
|
|
|
|
|
Category = plan.Category,
|
|
|
|
|
|
Source = plan.Source,
|
|
|
|
|
|
TypeInt = plan.TypeInt,
|
|
|
|
|
|
State = (int)TwConst.State.已完成,
|
|
|
|
|
|
CreateMan = plan.CreateMan,
|
2024-11-07 16:22:03 +08:00
|
|
|
|
CreateDate = plan.CreateDate,
|
2024-09-18 10:48:34 +08:00
|
|
|
|
ReqUnitId = plan.ReqUnitId,
|
2024-11-07 16:22:03 +08:00
|
|
|
|
AuditMan = plan.AuditMan,
|
|
|
|
|
|
AuditDate = plan.AuditDate,
|
2024-12-06 22:17:50 +08:00
|
|
|
|
AuditMan2 = plan.AuditMan2,
|
|
|
|
|
|
AuditDate2 = plan.AuditDate2,
|
2024-11-07 16:22:03 +08:00
|
|
|
|
WarehouseMan = plan.WarehouseMan,
|
2025-02-18 17:38:49 +08:00
|
|
|
|
WarehouseDate = plan.WarehouseDate,
|
2025-10-10 14:33:21 +08:00
|
|
|
|
|
|
|
|
|
|
};
|
2024-09-18 10:48:34 +08:00
|
|
|
|
Add(master);
|
|
|
|
|
|
//生成出库单明细
|
|
|
|
|
|
foreach (var detail in detailLists)
|
|
|
|
|
|
{
|
|
|
|
|
|
var detailTable = new Model.Tw_OutputDetail()
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = Guid.NewGuid().ToString(),
|
|
|
|
|
|
OutputMasterId = master.Id,
|
|
|
|
|
|
MaterialCode = detail.MaterialCode,
|
|
|
|
|
|
PlanNum = detail.PlanNum,
|
|
|
|
|
|
ActNum = detail.ActNum,
|
|
|
|
|
|
};
|
|
|
|
|
|
TwOutputdetailService.Add(detailTable);
|
|
|
|
|
|
TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.出库, detailTable.ActNum);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
plan.State = (int)TwConst.State.已完成;
|
2025-10-10 14:33:21 +08:00
|
|
|
|
TwInOutplanmasterService.Update(plan);
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据计划单撤销出库单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="planId"></param>
|
2024-09-24 20:38:50 +08:00
|
|
|
|
public static string RevokeGenOutMasterByPlanId(string planId)
|
2024-09-18 10:48:34 +08:00
|
|
|
|
{
|
2024-09-24 20:38:50 +08:00
|
|
|
|
string result = "";
|
2024-09-18 10:48:34 +08:00
|
|
|
|
Tw_InOutMasterOutput query = new Tw_InOutMasterOutput();
|
|
|
|
|
|
query.InOutPlanMasterId = planId;
|
|
|
|
|
|
var master = GetModle(query).FirstOrDefault();
|
|
|
|
|
|
if (master == null)
|
|
|
|
|
|
{
|
2024-09-24 20:38:50 +08:00
|
|
|
|
result = "未找到对应的出库单";
|
|
|
|
|
|
return result;
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
DeleteById(master.Id); //删除出库单
|
|
|
|
|
|
//删除明细
|
|
|
|
|
|
Tw_InOutDetailOutput queryDetail = new Tw_InOutDetailOutput();
|
|
|
|
|
|
queryDetail.OutputMasterId = master.Id;
|
|
|
|
|
|
var details = TwOutputdetailService.GetByModle(queryDetail).ToList();
|
|
|
|
|
|
foreach (var detail in details)
|
|
|
|
|
|
{
|
|
|
|
|
|
TwOutputdetailService.DeleteById(detail.Id);
|
|
|
|
|
|
//撤销出库,即增加库存
|
|
|
|
|
|
TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.入库, detail.ActNum);
|
|
|
|
|
|
}
|
2025-10-10 14:33:21 +08:00
|
|
|
|
var planModel = TwInOutplanmasterService.GetById(planId);
|
|
|
|
|
|
planModel.State = (int)TwConst.State.已审核;
|
2024-12-06 22:17:50 +08:00
|
|
|
|
planModel.WarehouseMan = null;
|
|
|
|
|
|
planModel.WarehouseDate = null;
|
2024-09-24 20:38:50 +08:00
|
|
|
|
TwInOutplanmasterService.Update(planModel);
|
|
|
|
|
|
return result;
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-18 17:38:49 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取出库单编号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
|
/// <param name="typeInt"></param>
|
|
|
|
|
|
/// <param name="category"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <param name="planCusBillCode"></param>
|
|
|
|
|
|
public static string GetCusBillCode(string taskCode, TwConst.TypeInt typeInt, TwConst.Category category, string planCusBillCode = "")
|
2024-09-18 10:48:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
string cusBillCode = "";
|
|
|
|
|
|
switch (typeInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TwConst.TypeInt.领料出库:
|
|
|
|
|
|
if (category == TwConst.Category.管段)
|
|
|
|
|
|
{
|
|
|
|
|
|
cusBillCode = taskCode + "-GI-P01";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (category == TwConst.Category.管件)
|
|
|
|
|
|
{
|
|
|
|
|
|
cusBillCode = taskCode + "-GI-PF01";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TwConst.TypeInt.补料出库:
|
|
|
|
|
|
if (category == TwConst.Category.管段)
|
|
|
|
|
|
{
|
|
|
|
|
|
cusBillCode = taskCode + "-GI-P01-SI01";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (category == TwConst.Category.管件)
|
|
|
|
|
|
{
|
|
|
|
|
|
cusBillCode = taskCode + "-GI-PF01-SI01";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
2025-02-18 17:38:49 +08:00
|
|
|
|
case TwConst.TypeInt.散件出库:
|
|
|
|
|
|
cusBillCode = planCusBillCode.Replace("-AP-", "-GI-");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TwConst.TypeInt.其他出库:
|
|
|
|
|
|
cusBillCode = planCusBillCode.Replace("-AP-", "-GI-");
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2024-09-18 10:48:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return cusBillCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|