Merge branch 'master' of https://gitee.com/frane-yang/SGGL_SeDin_New
This commit is contained in:
@@ -262,6 +262,15 @@
|
||||
<Compile Include="BaseInfo\UnitTypeService.cs" />
|
||||
<Compile Include="BaseInfo\WorkPostService.cs" />
|
||||
<Compile Include="BaseInfo\WorkStageService.cs" />
|
||||
<Compile Include="CLGL\TwArrivalStatisticsService.cs" />
|
||||
<Compile Include="CLGL\TwConst.cs" />
|
||||
<Compile Include="CLGL\TwInOutplandetailService.cs" />
|
||||
<Compile Include="CLGL\TwInOutplanmasterService.cs" />
|
||||
<Compile Include="CLGL\TwInputdetailService.cs" />
|
||||
<Compile Include="CLGL\TwInputmasterService.cs" />
|
||||
<Compile Include="CLGL\TwMaterialstockService.cs" />
|
||||
<Compile Include="CLGL\TwOutputdetailService..cs" />
|
||||
<Compile Include="CLGL\TwOutputmasterService.cs" />
|
||||
<Compile Include="Common\AttachFileService.cs" />
|
||||
<Compile Include="Common\CodeRecordsService.cs" />
|
||||
<Compile Include="Common\CommonService.cs" />
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class TwArrivalStatisticsService
|
||||
{
|
||||
public static IEnumerable GetStatistics(string projectid,string materialCode)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var NeedOutMateriaList = from x in db.HJGL_PipeLineMat
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId
|
||||
where z.ProjectId == projectid && (string.IsNullOrEmpty(materialCode) || x.MaterialCode .Contains( materialCode))
|
||||
group x by x.MaterialCode
|
||||
into g
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
NeedNum = g.Sum(x => x.Number) ?? 0,
|
||||
};
|
||||
|
||||
var RealInMateriaList = from x in db.Tw_InputDetail
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
group x by x.MaterialCode
|
||||
into g
|
||||
where (string.IsNullOrEmpty(materialCode) || g.Key.Contains( materialCode))
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
RealNum = g.Sum(x => x.ActNum) ?? 0,
|
||||
};
|
||||
|
||||
var StatisticsList =from x in NeedOutMateriaList
|
||||
join y in RealInMateriaList on x.Key equals y.Key into gg
|
||||
from y in gg.DefaultIfEmpty()
|
||||
join z in db.HJGL_MaterialCodeLib on x.Key equals z.MaterialCode into zz
|
||||
from z in zz.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
NeedNum = x.NeedNum,
|
||||
RealNum = y==null?0:y.RealNum,
|
||||
MaterialName = z.MaterialName,
|
||||
MaterialSpec=z.MaterialSpec,
|
||||
MaterialUnit=z.MaterialUnit,
|
||||
};
|
||||
return StatisticsList.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BLL;
|
||||
|
||||
public class TwConst
|
||||
{
|
||||
public enum InOutType : int
|
||||
{
|
||||
入库 = 1,
|
||||
出库 = 2,
|
||||
}
|
||||
public enum TypeInt : int
|
||||
{
|
||||
采购入库 = 10,
|
||||
退料入库 = 20,
|
||||
其他入库 = 30,
|
||||
领料出库 = 40,
|
||||
补料出库 = 50,
|
||||
其他出库 = 60,
|
||||
}
|
||||
public enum Category : int
|
||||
{
|
||||
全部 = 0,
|
||||
管件 = 1,
|
||||
管段 = 2,
|
||||
}
|
||||
public enum State : int
|
||||
{
|
||||
审核被拒 = -1,
|
||||
待提交 = 0,
|
||||
待审核 = 1,
|
||||
已审核 = 2,
|
||||
已完成 = 3,
|
||||
}
|
||||
public static Dictionary<string, int> TypeIntMap = new Dictionary<string, int>
|
||||
{
|
||||
{ "采购入库" ,(int)TypeInt.采购入库},
|
||||
{ "退料入库" ,(int)TypeInt.退料入库},
|
||||
{ "其他入库" ,(int)TypeInt.其他入库},
|
||||
{ "领料出库" ,(int)TypeInt.领料出库},
|
||||
{ "补料出库" ,(int)TypeInt.补料出库},
|
||||
{ "其他出库" ,(int)TypeInt.其他出库}
|
||||
};
|
||||
public static Dictionary<string, int> StateMap = new Dictionary<string, int>
|
||||
{
|
||||
{ "待提交" ,(int)State.待提交},
|
||||
{ "待审核" ,(int)State.待审核},
|
||||
{ "已审核" ,(int)State.已审核},
|
||||
{ "已完成" ,(int)State.已完成},
|
||||
{ "审核被拒" ,(int)State.审核被拒},
|
||||
};
|
||||
public static Dictionary<string, int> CategoryMap = new Dictionary<string, int>
|
||||
{
|
||||
{ "管件" ,(int)Category.管件},
|
||||
{ "管段" ,(int)Category.管段},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
using FineUIPro;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwInOutplandetailService
|
||||
{
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IQueryable<Model.Tw_InOutDetailOutput> GetByModle(Model.Tw_InOutDetailOutput table)
|
||||
{
|
||||
var q = from x in Funs.DB.Tw_InOutPlanDetail
|
||||
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) &&
|
||||
(string.IsNullOrEmpty(table.PipelineComponentId) || x.PipelineComponentId.Contains(table.PipelineComponentId)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode))
|
||||
select new Model.Tw_InOutDetailOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
InOutPlanMasterId = x.InOutPlanMasterId,
|
||||
PipelineComponentId = x.PipelineComponentId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
PlanNum = x.PlanNum,
|
||||
ActNum = x.ActNum,
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
}
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.Tw_InOutDetailOutput table, Grid grid1)
|
||||
{
|
||||
var q = GetByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select x;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_InOutPlanDetail GetById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_InOutPlanDetail.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
|
||||
public static void Add(Model.Tw_InOutPlanDetail newtable)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newtable.Id))
|
||||
{
|
||||
newtable.Id = SQLHelper.GetNewID();
|
||||
}
|
||||
Model.Tw_InOutPlanDetail table = new Model.Tw_InOutPlanDetail
|
||||
{
|
||||
Id = newtable.Id,
|
||||
InOutPlanMasterId = newtable.InOutPlanMasterId,
|
||||
PipelineComponentId = newtable.PipelineComponentId,
|
||||
MaterialCode = newtable.MaterialCode,
|
||||
PlanNum = newtable.PlanNum,
|
||||
ActNum = newtable.ActNum,
|
||||
};
|
||||
Funs.DB.Tw_InOutPlanDetail.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加计划明细
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="inoutPlanMasterId"></param>
|
||||
public static void AddList(IEnumerable<Model.Tw_InOutPlanDetail> list, string inoutPlanMasterId)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.Id= SQLHelper.GetNewID();
|
||||
item.InOutPlanMasterId = inoutPlanMasterId;
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
public static void Update(Model.Tw_InOutPlanDetail newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InOutPlanDetail table = Funs.DB.Tw_InOutPlanDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.InOutPlanMasterId = newtable.InOutPlanMasterId;
|
||||
table.PipelineComponentId = newtable.PipelineComponentId;
|
||||
table.MaterialCode = newtable.MaterialCode;
|
||||
table.PlanNum = newtable.PlanNum;
|
||||
table.ActNum = newtable.ActNum;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_InOutPlanDetail table = Funs.DB.Tw_InOutPlanDetail.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Tw_InOutPlanDetail.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void DeleteByInOutPlanMasterId (string inoutPlanMasterId)
|
||||
{
|
||||
var list = Funs.DB.Tw_InOutPlanDetail.Where(x => x.InOutPlanMasterId == inoutPlanMasterId);
|
||||
if (list != null)
|
||||
{
|
||||
Funs.DB.Tw_InOutPlanDetail.DeleteAllOnSubmit(list);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
using EmitMapper;
|
||||
using FineUIPro;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
using NPOI.Util;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwInOutplanmasterService
|
||||
{
|
||||
|
||||
#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_InOutPlanMaster
|
||||
join y in Funs.DB.HJGL_WeldTask on x.WeldTaskId equals y.WeldTaskId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join person in Funs.DB.Person_Persons on x.CreateMan equals person.PersonId into persons
|
||||
from person in persons.DefaultIfEmpty()
|
||||
join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units
|
||||
from unit in units.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(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.OutputMasterId) || x.OutputMasterId.Contains(table.OutputMasterId)) &&
|
||||
(string.IsNullOrEmpty(table.ReqUnitId) || x.ReqUnitId.Contains(table.ReqUnitId)) &&
|
||||
(string.IsNullOrEmpty(table.UnitWorkId) || x.WeldTaskId.Contains(table.UnitWorkId))&&
|
||||
(table.InOutType == null || x.InOutType == table.InOutType) &&
|
||||
(table.TypeInt == null || x.TypeInt == table.TypeInt) &&
|
||||
(table.Category == null || x.Category == table.Category) &&
|
||||
(table.State == null || x.State == table.State)
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
InOutType = x.InOutType,
|
||||
TypeInt = x.TypeInt,
|
||||
State = x.State,
|
||||
Category = x.Category,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = person.PersonName,
|
||||
CreateDate = x.CreateDate,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
WeldTaskId = x.WeldTaskId,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = unit.UnitName,
|
||||
UnitWorkId = y.UnitWorkId,
|
||||
WeldTaskCode = y.TaskCode
|
||||
}
|
||||
;
|
||||
|
||||
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();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in result
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
InOutType = x.InOutType,
|
||||
TypeInt = x.TypeInt,
|
||||
Category = x.Category,
|
||||
State = x.State,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
WeldTaskId = x.WeldTaskId,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
UnitWorkId = x.UnitWorkId,
|
||||
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 == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode :"":"",
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Tw_InOutMasterOutput> GetListData(Model.Tw_InOutMasterOutput table)
|
||||
{
|
||||
|
||||
var q = GetModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = q.ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return (from x in result
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
InOutType = x.InOutType,
|
||||
TypeInt = x.TypeInt,
|
||||
Category = x.Category,
|
||||
State = x.State,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
WeldTaskId = x.WeldTaskId,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
UnitWorkId = x.UnitWorkId,
|
||||
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 == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode : "" : "",
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="projectid"></param>
|
||||
/// <param name="creatUserId"></param>
|
||||
/// <returns></returns>
|
||||
public static ResponeData ImportData(string path, string projectid, string creatUserId)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<Tw_InputDataIn> temeplateDtoIns;
|
||||
try
|
||||
{
|
||||
temeplateDtoIns = MiniExcel.Query<Tw_InputDataIn>(path, startCell: "A1").ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "模板错误:" + ex.ToString();
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#region 数据校验
|
||||
if (temeplateDtoIns.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "导入数据为空!";
|
||||
return responeData;
|
||||
}
|
||||
var queryAll = new Tw_InOutMasterOutput()
|
||||
{
|
||||
ProjectId = projectid
|
||||
};
|
||||
var warehouseCodeList = temeplateDtoIns.Select(x => x.WarehouseCode).Distinct().ToList(); //获取导入文件的仓库编号
|
||||
string errorWarehouseCode = "";
|
||||
foreach (var item in warehouseCodeList)
|
||||
{
|
||||
if (!DropListService.HJGL_WarehouseCode().Select(x=>x.Value== item).Any())
|
||||
{
|
||||
errorWarehouseCode+=item+",";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(errorWarehouseCode))
|
||||
{
|
||||
if (temeplateDtoIns.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = errorWarehouseCode+"仓库不存在!";
|
||||
return responeData;
|
||||
}
|
||||
}
|
||||
var materialCodeList = temeplateDtoIns.Select(x => x.MaterialCode).Distinct().ToList(); //获取导入文件的材料编码
|
||||
var IsExitMaterialCode=
|
||||
from x in Funs.DB.HJGL_MaterialCodeLib
|
||||
where materialCodeList.Contains(x.MaterialCode)
|
||||
select x.MaterialCode;
|
||||
if (IsExitMaterialCode.Count() < materialCodeList.Count)
|
||||
{
|
||||
var errorMaterialCode = materialCodeList.Except(IsExitMaterialCode.ToList());
|
||||
if (errorMaterialCode.Count() > 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Join(",", errorMaterialCode) + "材料不存在!";
|
||||
return responeData;
|
||||
}
|
||||
}
|
||||
|
||||
var queryAllresult = GetModle(queryAll).Select(x => x.CusBillCode).Distinct().ToList();//查询所有的编号
|
||||
var CusBillCodeList = temeplateDtoIns.Select(x => x.CusBillCode).Distinct().ToList(); //获取导入文件的编号
|
||||
var IsContain = CusBillCodeList.Intersect(queryAllresult).ToList(); //判断导入文件中是有已存在的编号
|
||||
if (IsContain.Count>0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Join(",", IsContain)+ "编号已存在!";
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
//根据申请单编号分组插入数据
|
||||
foreach (var CusBillCode in CusBillCodeList)
|
||||
{
|
||||
var CusBillCodeDtoIns = temeplateDtoIns.Where(x => x.CusBillCode == CusBillCode).ToList();
|
||||
|
||||
var mapper =
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<Tw_InputDataIn>, List<Model.Tw_InOutPlanMaster>>();
|
||||
var mapperDetail =
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<Tw_InputDataIn>, List<Tw_InOutPlanDetail>>();
|
||||
//通过映射实体赋值
|
||||
var twInOutPlanMaster = mapper.Map(CusBillCodeDtoIns).FirstOrDefault();
|
||||
var twInOutPlanDetails = mapperDetail.Map(CusBillCodeDtoIns.Where(x => !string.IsNullOrEmpty(x.MaterialCode) && !string.IsNullOrEmpty(x.PlanNum)).ToList());
|
||||
|
||||
twInOutPlanMaster.Id = SQLHelper.GetNewID();
|
||||
twInOutPlanMaster.InOutType= (int)TwConst.InOutType.入库;
|
||||
twInOutPlanMaster.State = (int)TwConst.State.待审核;
|
||||
twInOutPlanMaster.TypeInt= (int)TwConst.TypeInt.采购入库;
|
||||
twInOutPlanMaster.Category= (int)TwConst.Category.全部;
|
||||
twInOutPlanMaster.ProjectId = projectid;
|
||||
twInOutPlanMaster.CreateMan = creatUserId;
|
||||
twInOutPlanMaster.CreateDate = DateTime.Now;
|
||||
Add(twInOutPlanMaster);
|
||||
TwInOutplandetailService.AddList(twInOutPlanDetails, twInOutPlanMaster.Id); //插入入库明细
|
||||
|
||||
}
|
||||
return responeData;
|
||||
|
||||
}
|
||||
|
||||
public static Model.Tw_InOutPlanMaster GetById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
public static void Add(Model.Tw_InOutPlanMaster newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster
|
||||
{
|
||||
Id = newtable.Id,
|
||||
ProjectId = newtable.ProjectId,
|
||||
CusBillCode = newtable.CusBillCode,
|
||||
WarehouseCode = newtable.WarehouseCode,
|
||||
Source = newtable.Source,
|
||||
Category = newtable.Category,
|
||||
InOutType = newtable.InOutType,
|
||||
TypeInt = newtable.TypeInt,
|
||||
State = newtable.State,
|
||||
CreateMan = newtable.CreateMan,
|
||||
CreateDate = newtable.CreateDate,
|
||||
OutputMasterId = newtable.OutputMasterId,
|
||||
WeldTaskId = newtable.WeldTaskId,
|
||||
ReqUnitId = newtable.ReqUnitId,
|
||||
};
|
||||
Funs.DB.Tw_InOutPlanMaster.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
public static void Update(Model.Tw_InOutPlanMaster newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InOutPlanMaster table = Funs.DB.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.ProjectId = newtable.ProjectId;
|
||||
table.CusBillCode = newtable.CusBillCode;
|
||||
table.WarehouseCode = newtable.WarehouseCode;
|
||||
table.Category = newtable.Category;
|
||||
table.Source = newtable.Source;
|
||||
table.InOutType = newtable.InOutType;
|
||||
table.TypeInt = newtable.TypeInt;
|
||||
table.State = newtable.State;
|
||||
table.CreateMan = newtable.CreateMan;
|
||||
table.CreateDate = newtable.CreateDate;
|
||||
table.OutputMasterId = newtable.OutputMasterId;
|
||||
table.WeldTaskId = newtable.WeldTaskId;
|
||||
table.ReqUnitId = newtable.ReqUnitId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_InOutPlanMaster table = Funs.DB.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
TwInOutplandetailService.DeleteByInOutPlanMasterId(table.Id);
|
||||
|
||||
Funs.DB.Tw_InOutPlanMaster.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据出库单生成计划单
|
||||
/// </summary>
|
||||
/// <param name="outputMasterId"></param>
|
||||
/// <param name="typeInt"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenPlanMasterByOutputMasterId(string outputMasterId,TwConst.TypeInt typeInt)
|
||||
{
|
||||
string message = "";
|
||||
|
||||
#region 数据校验
|
||||
|
||||
//获取出库单
|
||||
var outMasterQuery = new Tw_InOutMasterOutput();
|
||||
outMasterQuery.Id = outputMasterId;
|
||||
var outMaster = TwOutputmasterService.GetListData(outMasterQuery) .FirstOrDefault() ;
|
||||
if (outMaster == null || outMaster.State != (int)TwConst.State.已完成)
|
||||
{
|
||||
message = "出库单状态错误,无法生成计划单!";
|
||||
return message;
|
||||
}
|
||||
//判断是否已经生成过计划单
|
||||
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
||||
queryIsExitInMaster.OutputMasterId = outMaster.Id;
|
||||
queryIsExitInMaster.TypeInt= (int)typeInt;
|
||||
var IsExitInMaster = GetModle(queryIsExitInMaster).FirstOrDefault();
|
||||
if (IsExitInMaster != null)
|
||||
{
|
||||
message = "该出库单已生成过计划单";
|
||||
return message;
|
||||
}
|
||||
//明细校验
|
||||
Tw_InOutDetailOutput query = new Tw_InOutDetailOutput();
|
||||
query.OutputMasterId = outputMasterId;
|
||||
var details = TwOutputdetailService.GetByModle(query).ToList();
|
||||
switch (typeInt)
|
||||
{
|
||||
case TwConst.TypeInt.补料出库:
|
||||
details = details.Where(x => x.PlanNum > x.ActNum).ToList();
|
||||
foreach (var item in details)
|
||||
{
|
||||
item.PlanNum = (item.PlanNum - item.ActNum);
|
||||
}
|
||||
if (details.Count==0)
|
||||
{
|
||||
message = "该出库单无需补料";
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
case TwConst.TypeInt.退料入库:
|
||||
details = details.Where(x => x.PlanNum < x.ActNum).ToList();
|
||||
foreach (var item in details)
|
||||
{
|
||||
item.PlanNum = (item.ActNum - item.PlanNum);
|
||||
}
|
||||
if (details.Count == 0)
|
||||
{
|
||||
message = "该出库单无需退料";
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
//生成计划单
|
||||
var planMasterModel = new Model.Tw_InOutMasterOutput()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
OutputMasterId = outMaster.Id,
|
||||
ProjectId = outMaster.ProjectId,
|
||||
WarehouseCode = outMaster.WarehouseCode,
|
||||
Source = 2,
|
||||
Category = outMaster.Category,
|
||||
TypeInt = outMaster.TypeInt,
|
||||
State = (int)TwConst.State.待审核,
|
||||
CreateMan = outMaster.CreateMan,
|
||||
CreateDate = DateTime.Now,
|
||||
ReqUnitId = outMaster.ReqUnitId,
|
||||
WeldTaskId = GetById(outMaster.InOutPlanMasterId).WeldTaskId
|
||||
|
||||
};
|
||||
switch (typeInt)
|
||||
{
|
||||
case TwConst.TypeInt.补料出库:
|
||||
planMasterModel.CusBillCode = GetCusBillCodeByTaskCode(outMaster.WeldTaskCode,TwConst.TypeInt.补料出库,(BLL.TwConst.Category)planMasterModel.Category);
|
||||
planMasterModel.TypeInt= (int)TwConst.TypeInt.补料出库;
|
||||
planMasterModel.InOutType= (int)TwConst.InOutType.出库;
|
||||
break;
|
||||
case TwConst.TypeInt.退料入库:
|
||||
planMasterModel.CusBillCode = GetCusBillCodeByTaskCode(outMaster.WeldTaskCode, TwConst.TypeInt.退料入库, (BLL.TwConst.Category)planMasterModel.Category);
|
||||
planMasterModel.TypeInt = (int)TwConst.TypeInt.退料入库;
|
||||
planMasterModel.InOutType = (int)TwConst.InOutType.入库;
|
||||
;
|
||||
break;
|
||||
}
|
||||
Add(planMasterModel);
|
||||
//生成明细
|
||||
TwInOutplandetailService.AddList(details, planMasterModel.Id);
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string GetCusBillCodeByTaskCode(string taskCode,TwConst.TypeInt typeInt,TwConst.Category category )
|
||||
{
|
||||
string cusBillCode = "";
|
||||
switch (typeInt )
|
||||
{
|
||||
case TwConst.TypeInt.领料出库:
|
||||
if (category== TwConst.Category.管段)
|
||||
{
|
||||
cusBillCode = taskCode + "-AP-P01";
|
||||
}
|
||||
else if (category == TwConst.Category.管件)
|
||||
{
|
||||
cusBillCode = taskCode + "-AP-PF01";
|
||||
}
|
||||
|
||||
break;
|
||||
case TwConst.TypeInt.补料出库:
|
||||
if (category == TwConst.Category.管段)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-P01-AP01";
|
||||
}
|
||||
else if (category == TwConst.Category.管件)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-PF01-AP01";
|
||||
}
|
||||
|
||||
break;
|
||||
case TwConst.TypeInt.退料入库:
|
||||
if (category == TwConst.Category.管段)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-P01-RE01";
|
||||
}
|
||||
else if (category == TwConst.Category.管件)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-PF01-RE01";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return cusBillCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
using FineUIPro;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwInputdetailService
|
||||
{
|
||||
|
||||
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IQueryable<Model.Tw_InOutDetailOutput> GetByModle(Model.Tw_InOutDetailOutput table)
|
||||
{
|
||||
var q = from x in Funs.DB.Tw_InputDetail
|
||||
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.InputMasterId) || x.InputMasterId.Contains(table.InputMasterId)) &&
|
||||
(string.IsNullOrEmpty(table.PipelineComponentId) || x.PipelineComponentId.Contains(table.PipelineComponentId)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode))
|
||||
select new Model.Tw_InOutDetailOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
InputMasterId = x.InputMasterId,
|
||||
PipelineComponentId = x.PipelineComponentId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
PlanNum = x.PlanNum,
|
||||
ActNum = x.ActNum,
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
}
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.Tw_InOutDetailOutput table, Grid grid1)
|
||||
{
|
||||
var q = GetByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select x;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_InputDetail GetById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
public static void Add(Model.Tw_InputDetail newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InputDetail table = new Model.Tw_InputDetail
|
||||
{
|
||||
Id = newtable.Id,
|
||||
InputMasterId = newtable.InputMasterId,
|
||||
PipelineComponentId = newtable.PipelineComponentId,
|
||||
MaterialCode = newtable.MaterialCode,
|
||||
PlanNum = newtable.PlanNum,
|
||||
ActNum = newtable.ActNum,
|
||||
};
|
||||
Funs.DB.Tw_InputDetail.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void Update(Model.Tw_InputDetail newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InputDetail table = Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.InputMasterId = newtable.InputMasterId;
|
||||
table.PipelineComponentId = newtable.PipelineComponentId;
|
||||
table.MaterialCode = newtable.MaterialCode;
|
||||
table.PlanNum = newtable.PlanNum;
|
||||
table.ActNum = newtable.ActNum;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_InputDetail table = Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Tw_InputDetail.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwInputmasterService
|
||||
{
|
||||
#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_InputMaster
|
||||
join person in Funs.DB.Person_Persons on x.CreateMan equals person.PersonId into persons
|
||||
from person in persons.DefaultIfEmpty()
|
||||
join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units
|
||||
from unit in units.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(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)) &&
|
||||
(table.TypeInt == null || x.TypeInt == table.TypeInt) &&
|
||||
(table.Category == null || x.Category == table.Category) &&
|
||||
(table.State == null || x.State == table.State)
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
InOutPlanMasterId = x.InOutPlanMasterId,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
Category = x.Category,
|
||||
TypeInt = x.TypeInt,
|
||||
State = x.State,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = person.PersonName,
|
||||
CreateDate = x.CreateDate,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = unit.UnitName,
|
||||
};
|
||||
|
||||
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();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in result
|
||||
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,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
Category = x.Category,
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Tw_InOutMasterOutput> GetListData(Model.Tw_InOutMasterOutput table )
|
||||
{
|
||||
var q = GetModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = q.ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return (from x in result
|
||||
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,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
Category = x.Category,
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
}).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_InputMaster GetById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_InputMaster.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
|
||||
public static void Add(Model.Tw_InputMaster newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InputMaster table = new Model.Tw_InputMaster
|
||||
{
|
||||
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,
|
||||
ReqUnitId = newtable.ReqUnitId,
|
||||
};
|
||||
Funs.DB.Tw_InputMaster.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void Update(Model.Tw_InputMaster newtable)
|
||||
{
|
||||
|
||||
Model.Tw_InputMaster table = Funs.DB.Tw_InputMaster.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;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_InputMaster table = Funs.DB.Tw_InputMaster.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Tw_InputMaster.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划单生成入库单
|
||||
/// </summary>
|
||||
public static void GenInMasterByPlanId(string planId)
|
||||
{
|
||||
//获取计划单
|
||||
var planQueryModel = new Tw_InOutMasterOutput();
|
||||
planQueryModel.Id = planId;
|
||||
var plan = TwInOutplanmasterService.GetListData(planQueryModel).FirstOrDefault();
|
||||
if (plan == null || plan.State!= (int)TwConst.State.已审核)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//判断是否已经生成过入库单
|
||||
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
||||
queryIsExitInMaster.InOutPlanMasterId = planId;
|
||||
queryIsExitInMaster.TypeInt = plan.TypeInt;
|
||||
queryIsExitInMaster.Category = plan.Category;
|
||||
var IsExitInMaster = GetModle(queryIsExitInMaster).FirstOrDefault();
|
||||
if (IsExitInMaster != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//生成入库单
|
||||
var master = new Model.Tw_InputMaster()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = plan.Id,
|
||||
ProjectId = plan.ProjectId,
|
||||
WarehouseCode = plan.WarehouseCode,
|
||||
Source = plan.Source,
|
||||
TypeInt = plan.TypeInt,
|
||||
Category = plan.Category,
|
||||
State = (int)TwConst.State.已完成,
|
||||
CreateMan = plan.CreateMan,
|
||||
CreateDate = DateTime.Now,
|
||||
ReqUnitId = plan.ReqUnitId,
|
||||
};
|
||||
if ((TwConst.TypeInt)plan.TypeInt!= TwConst.TypeInt.采购入库)
|
||||
{
|
||||
master.CusBillCode = GetCusBillCodeByTaskCode(plan.WeldTaskCode, (TwConst.TypeInt)plan.TypeInt,
|
||||
(BLL.TwConst.Category)plan.Category);
|
||||
|
||||
}
|
||||
Add(master);
|
||||
//生成明细
|
||||
Tw_InOutDetailOutput query = new Tw_InOutDetailOutput();
|
||||
query.InOutPlanMasterId= planId;
|
||||
var details = TwInOutplandetailService.GetByModle(query).ToList();
|
||||
foreach (var detail in details)
|
||||
{
|
||||
var detailTable = new Model.Tw_InputDetail()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InputMasterId = master.Id,
|
||||
MaterialCode = detail.MaterialCode,
|
||||
PlanNum = detail.PlanNum,
|
||||
ActNum = detail.PlanNum,
|
||||
};
|
||||
TwInputdetailService.Add(detailTable);
|
||||
TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.入库, detailTable.ActNum);
|
||||
|
||||
}
|
||||
plan.State= (int)TwConst.State.已完成;
|
||||
TwInOutplanmasterService.Update(plan);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据计划单撤销入库单
|
||||
/// </summary>
|
||||
/// <param name="planId"></param>
|
||||
public static void RevokeGenInMasterByPlanId(string planId)
|
||||
{
|
||||
//校验计划单状态
|
||||
var plan = TwInOutplanmasterService.GetById(planId);
|
||||
if (plan == null || plan.State != (int)TwConst.State.已完成)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//获取入库单
|
||||
Tw_InOutMasterOutput query = new Tw_InOutMasterOutput();
|
||||
query.InOutPlanMasterId = planId;
|
||||
var master = GetModle(query).FirstOrDefault();
|
||||
if (master == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DeleteById(master.Id); //删除入库单
|
||||
//删除明细
|
||||
Tw_InOutDetailOutput queryDetail = new Tw_InOutDetailOutput();
|
||||
queryDetail.InputMasterId = master.Id;
|
||||
var details = TwInputdetailService.GetByModle(queryDetail).ToList();
|
||||
foreach (var detail in details)
|
||||
{
|
||||
TwInputdetailService.DeleteById(detail.Id);
|
||||
//撤销入库,即减去库存
|
||||
TwMaterialstockService.UpdateStockNum(master.ProjectId,detail.MaterialCode, master.WarehouseCode,TwConst.InOutType.出库, detail.ActNum);
|
||||
}
|
||||
plan.State = (int)TwConst.State.已审核;
|
||||
TwInOutplanmasterService.Update(plan);
|
||||
|
||||
}
|
||||
public static string GetCusBillCodeByTaskCode(string taskCode, TwConst.TypeInt typeInt, TwConst.Category category)
|
||||
{
|
||||
string cusBillCode = "";
|
||||
switch (typeInt)
|
||||
{
|
||||
case TwConst.TypeInt.退料入库:
|
||||
if (category == TwConst.Category.管段)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-P01-RE01";
|
||||
}
|
||||
else if (category == TwConst.Category.管件)
|
||||
{
|
||||
cusBillCode = taskCode + "-GI-PF01-RE01";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return cusBillCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
using FineUIPro;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwMaterialstockService
|
||||
{
|
||||
|
||||
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IQueryable<Model.Tw_MaterialStockOutput> GetTw_MaterialStockByModle(Model.Tw_MaterialStockOutput table)
|
||||
{
|
||||
var q = from x in Funs.DB.Tw_MaterialStock
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.PipeLineMatCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) &&
|
||||
(string.IsNullOrEmpty(table.PipeLineMatCode) || x.PipeLineMatCode.Contains(table.PipeLineMatCode)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId))
|
||||
select new Model.Tw_MaterialStockOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
PipeLineMatCode = x.PipeLineMatCode,
|
||||
StockNum = x.StockNum,
|
||||
ProjectId = x.ProjectId,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialSpec = mat.MaterialSpec,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
}
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.Tw_MaterialStockOutput table, Grid grid1)
|
||||
{
|
||||
var q = GetTw_MaterialStockByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select x;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_MaterialStock GetTw_MaterialStockById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
public static void AddTw_MaterialStock(Model.Tw_MaterialStock newtable)
|
||||
{
|
||||
|
||||
Model.Tw_MaterialStock table = new Model.Tw_MaterialStock
|
||||
{
|
||||
Id = newtable.Id,
|
||||
WarehouseCode = newtable.WarehouseCode,
|
||||
PipeLineMatCode = newtable.PipeLineMatCode,
|
||||
StockNum = newtable.StockNum,
|
||||
ProjectId = newtable.ProjectId,
|
||||
};
|
||||
Funs.DB.Tw_MaterialStock.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdateTw_MaterialStock(Model.Tw_MaterialStock newtable)
|
||||
{
|
||||
|
||||
Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.WarehouseCode = newtable.WarehouseCode;
|
||||
table.PipeLineMatCode = newtable.PipeLineMatCode;
|
||||
table.StockNum = newtable.StockNum;
|
||||
table.ProjectId = newtable.ProjectId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteTw_MaterialStockById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Tw_MaterialStock.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目编码,材料编码,仓库编码,数量增减库存
|
||||
/// </summary>
|
||||
/// <param name="ProjectId"></param>
|
||||
/// <param name="MaterialCode"></param>
|
||||
/// <param name="WarehouseCode"></param>
|
||||
/// <param name="inOutType"></param>
|
||||
/// <param name="StockNum"></param>
|
||||
public static void UpdateStockNum(string ProjectId, string MaterialCode, string WarehouseCode,TwConst.InOutType inOutType , decimal? StockNum)
|
||||
{
|
||||
Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.ProjectId == ProjectId && x.PipeLineMatCode == MaterialCode && x.WarehouseCode == WarehouseCode);
|
||||
//如果是入库,则库存数量加上,如果是出库,则库存数量减去
|
||||
if (inOutType==TwConst.InOutType.出库)
|
||||
{
|
||||
StockNum=-StockNum;//出库,库存数量减去
|
||||
}
|
||||
if (table != null)
|
||||
{
|
||||
table.StockNum = table.StockNum ?? 0;
|
||||
table.StockNum += StockNum;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.Tw_MaterialStock newtable = new Model.Tw_MaterialStock
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = ProjectId,
|
||||
PipeLineMatCode = MaterialCode,
|
||||
WarehouseCode = WarehouseCode,
|
||||
StockNum = StockNum??0,
|
||||
};
|
||||
Funs.DB.Tw_MaterialStock.InsertOnSubmit(newtable);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using FineUIPro;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class TwOutputdetailService
|
||||
{
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IQueryable<Model.Tw_InOutDetailOutput> GetByModle(Model.Tw_InOutDetailOutput table)
|
||||
{
|
||||
var q = from x in Funs.DB.Tw_OutputDetail
|
||||
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.OutputMasterId) || x.OutputMasterId.Contains(table.OutputMasterId)) &&
|
||||
(string.IsNullOrEmpty(table.PipelineComponentId) || x.PipelineComponentId.Contains(table.PipelineComponentId)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode))
|
||||
select new Model.Tw_InOutDetailOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
PipelineComponentId = x.PipelineComponentId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
PlanNum = x.PlanNum,
|
||||
ActNum = x.ActNum,
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
}
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.Tw_InOutDetailOutput table, Grid grid1)
|
||||
{
|
||||
var q = GetByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select x;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Tw_OutputDetail GetById(string Id)
|
||||
{
|
||||
return Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
|
||||
public static void Add(Model.Tw_OutputDetail newtable)
|
||||
{
|
||||
|
||||
Model.Tw_OutputDetail table = new Model.Tw_OutputDetail
|
||||
{
|
||||
Id = newtable.Id,
|
||||
OutputMasterId = newtable.OutputMasterId,
|
||||
PipelineComponentId = newtable.PipelineComponentId,
|
||||
MaterialCode = newtable.MaterialCode,
|
||||
PlanNum = newtable.PlanNum,
|
||||
ActNum = newtable.ActNum,
|
||||
};
|
||||
Funs.DB.Tw_OutputDetail.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
public static void Update(Model.Tw_OutputDetail newtable)
|
||||
{
|
||||
|
||||
Model.Tw_OutputDetail table = Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.OutputMasterId = newtable.OutputMasterId;
|
||||
table.PipelineComponentId = newtable.PipelineComponentId;
|
||||
table.MaterialCode = newtable.MaterialCode;
|
||||
table.PlanNum = newtable.PlanNum;
|
||||
table.ActNum = newtable.ActNum;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
|
||||
Model.Tw_OutputDetail table = Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Tw_OutputDetail.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库单逻辑层
|
||||
/// </summary>
|
||||
public static class TwOutputmasterService
|
||||
{
|
||||
#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
|
||||
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()
|
||||
join person in Funs.DB.Person_Persons on x.CreateMan equals person.PersonId into persons
|
||||
from person in persons.DefaultIfEmpty()
|
||||
join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units
|
||||
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)
|
||||
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,
|
||||
};
|
||||
|
||||
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
|
||||
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 == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode : "" : "",
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Tw_InOutMasterOutput> GetListData(Model.Tw_InOutMasterOutput table)
|
||||
{
|
||||
var q = GetModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = q.ToList();
|
||||
return (from x in result
|
||||
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 == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode : "" : "",
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#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,
|
||||
ReqUnitId = newtable.ReqUnitId,
|
||||
};
|
||||
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;
|
||||
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();
|
||||
planQueryModel.Id = planId;
|
||||
var plan = TwInOutplanmasterService.GetListData(planQueryModel).FirstOrDefault();
|
||||
if (plan == null || plan.State != (int)TwConst.State.已审核)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//判断是否已经生成过出库单
|
||||
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
||||
queryIsExitInMaster.InOutPlanMasterId = planId;
|
||||
queryIsExitInMaster.TypeInt= plan.TypeInt;
|
||||
var IsExitInMaster = GetModle(queryIsExitInMaster).FirstOrDefault();
|
||||
if (IsExitInMaster != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//生成出库单
|
||||
var master = new Model.Tw_OutputMaster()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = plan.Id,
|
||||
ProjectId = plan.ProjectId,
|
||||
CusBillCode = GetCusBillCodeByTaskCode(plan.WeldTaskCode, (TwConst.TypeInt)plan.TypeInt, (BLL.TwConst.Category)plan.Category),
|
||||
WarehouseCode = plan.WarehouseCode,
|
||||
Category = plan.Category,
|
||||
Source = plan.Source,
|
||||
TypeInt = plan.TypeInt,
|
||||
State = (int)TwConst.State.已完成,
|
||||
CreateMan = plan.CreateMan,
|
||||
CreateDate = DateTime.Now,
|
||||
ReqUnitId = plan.ReqUnitId,
|
||||
};
|
||||
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.已完成;
|
||||
TwInOutplanmasterService.Update(plan);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据计划单撤销出库单
|
||||
/// </summary>
|
||||
/// <param name="planId"></param>
|
||||
public static void RevokeGenOutMasterByPlanId(string planId)
|
||||
{
|
||||
Tw_InOutMasterOutput query = new Tw_InOutMasterOutput();
|
||||
query.InOutPlanMasterId = planId;
|
||||
var master = GetModle(query).FirstOrDefault();
|
||||
if (master == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static string GetCusBillCodeByTaskCode(string taskCode, TwConst.TypeInt typeInt, TwConst.Category category)
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
return cusBillCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4870,6 +4870,31 @@ namespace BLL
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region 材料管理
|
||||
public const string Tw_InPlanMasteTemplateUrl = "File\\Excel\\DataIn\\材料入库导入模板.xlsx";
|
||||
/// <summary>
|
||||
/// 入库申请
|
||||
/// </summary>
|
||||
public const string Tw_InPlanMasterMenuId = "324C72AF-447A-4308-AFB7-ABF788C58240";
|
||||
/// <summary>
|
||||
/// 入库单管理
|
||||
/// </summary>
|
||||
public const string Tw_InputMasterMenuId = "4A55351A-2440-4A2D-8509-3FFEE5FC8861";
|
||||
/// <summary>
|
||||
/// 出库申请
|
||||
/// </summary>
|
||||
public const string Tw_OutPlanMasterMenuId = "E910F410-07FB-41C3-AA80-8E30D1563BC1";
|
||||
/// <summary>
|
||||
/// 出库单管理
|
||||
/// </summary>
|
||||
public const string Tw_OutputMasterMenuId = "BCCA4D81-410C-4746-B1E4-F882BC3A25F4";
|
||||
/// <summary>
|
||||
/// 库存管理
|
||||
/// </summary>
|
||||
public const string Tw_MaterialStockMenuId = "803F9828-52FA-4EF7-99C7-ADA99DADE9FB";
|
||||
#endregion
|
||||
|
||||
#region 合同附件Id
|
||||
/// <summary>
|
||||
/// 招标文件台账模板
|
||||
|
||||
@@ -240,7 +240,13 @@ namespace BLL
|
||||
list[1] = new ListItem("预制", "预制");
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ListItem[] HJGL_WarehouseCode()
|
||||
{
|
||||
ListItem[] list = new ListItem[2];
|
||||
list[0] = new ListItem("现场安装", "现场安装");
|
||||
list[1] = new ListItem("工厂预制", "工厂预制");
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 机动化程度
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Numerics;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -29,7 +32,7 @@ namespace BLL
|
||||
///获取焊接任务单编号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetTaskCodeByDate(string projectId, string date)
|
||||
public static string GetTaskCodeByDate(string projectId, string date,string unitworkid,string unitid)
|
||||
{
|
||||
string code = string.Empty;
|
||||
var list = (from x in Funs.DB.HJGL_WeldTask where x.ProjectId == projectId && x.TaskDate == Convert.ToDateTime(date) orderby x.TaskCode descending select x.TaskCode).Distinct().ToList();
|
||||
@@ -62,6 +65,7 @@ namespace BLL
|
||||
{
|
||||
code = date + "-001";
|
||||
}
|
||||
code = code.Replace("-", "") + "-" + UnitService.GetUnitCodeByUnitId(unitid) + "-" + UnitWorkService.getUnitWorkByUnitWorkId(unitworkid)?.UnitWorkCode;
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -305,6 +309,113 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void GenOutPlanmasterByWeldTaskId(string unitworkid,string unitid,DateTime date,string Personid)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.View_HJGL_WeldingTask weldTask = db.View_HJGL_WeldingTask.FirstOrDefault(e => e.UnitWorkId==unitworkid && e.UnitId==unitid&& e.TaskDate.Value.Date==date.Date);
|
||||
if (weldTask==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string WeldTaskId= unitworkid+"|"+unitid+ "|" + string.Format("{0:yyyyMMMMdd}", date);
|
||||
//判断是否已经生成过出库计划单
|
||||
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
||||
queryIsExitInMaster.WeldTaskId = WeldTaskId;
|
||||
queryIsExitInMaster.InOutType=(int)TwConst.InOutType.出库;
|
||||
queryIsExitInMaster.TypeInt = (int)TwConst.TypeInt.领料出库;
|
||||
var IsExitInMaster = TwInOutplanmasterService.GetModle(queryIsExitInMaster).FirstOrDefault();
|
||||
if (IsExitInMaster != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var pipelineList = db.View_HJGL_WeldingTask.Where(e => e.UnitWorkId == unitworkid && e.UnitId == unitid && e.TaskDate.Value.Date == date.Date).Select(x=>x.PipelineId).Distinct().ToList();
|
||||
|
||||
//var outMateriaList = db.HJGL_PipeLineMat.Where(x => pipelineList.Contains(x.PipelineId))
|
||||
// .GroupBy(x => x.MaterialCode).Select(x => new
|
||||
// {
|
||||
// x.Key,
|
||||
// planNum = x.Sum(y => y.Number)??0,
|
||||
// }).ToList();
|
||||
var outMateriaList = from x in db.HJGL_PipeLineMat
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
where pipelineList.Contains(x.PipelineId)
|
||||
group x by new { x.MaterialCode, y.MaterialUnit }
|
||||
into g
|
||||
select new
|
||||
{
|
||||
g.Key.MaterialCode,
|
||||
planNum = g.Sum(x => x.Number) ?? 0,
|
||||
MaterialName = g.Key.MaterialUnit,
|
||||
};
|
||||
|
||||
var outPlanDetailListPiece = outMateriaList.Where(x => x.MaterialName.Contains("个"));//管件
|
||||
var outPlanDetailListOthere = outMateriaList.Where(x => x.MaterialName.Contains("米"));//管段
|
||||
var weldTaskCode = GetWeldTaskById(weldTask.WeldTaskId)?.TaskCode;
|
||||
if (outPlanDetailListPiece.Any())
|
||||
{
|
||||
Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = weldTask.ProjectId,
|
||||
// CusBillCode = string.Format("{0:yyyyMMdd}", DateTime.Now) + UnitService.GetUnitCodeByUnitId(weldTask.UnitId) + "-" + UnitWorkService.getUnitWorkByUnitWorkId(weldTask.UnitWorkId)?.UnitWorkCode + "AP-PF01",
|
||||
CusBillCode=TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode,TwConst.TypeInt.领料出库,TwConst.Category.管件),
|
||||
WarehouseCode = PipelineService.GetPipeArea().Where(x => x.Value == PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).PipeArea).Select(x => x.Text).FirstOrDefault(),
|
||||
Source = 1,
|
||||
InOutType = (int)TwConst.InOutType.出库,
|
||||
TypeInt = (int)TwConst.TypeInt.领料出库,
|
||||
State = (int)TwConst.State.待审核,
|
||||
Category = (int)TwConst.Category.管件,
|
||||
CreateMan = Personid,
|
||||
CreateDate = DateTime.Now,
|
||||
WeldTaskId = WeldTaskId,
|
||||
ReqUnitId = weldTask.UnitId,
|
||||
};
|
||||
TwInOutplanmasterService.Add(table);
|
||||
foreach (var item in outPlanDetailListPiece)
|
||||
{
|
||||
Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = table.Id,
|
||||
MaterialCode = item.MaterialCode,
|
||||
PlanNum = item.planNum,
|
||||
};
|
||||
TwInOutplandetailService.Add(detail);
|
||||
}
|
||||
}
|
||||
if (outPlanDetailListOthere.Any())
|
||||
{
|
||||
Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = weldTask.ProjectId,
|
||||
CusBillCode =TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode, TwConst.TypeInt.领料出库, TwConst.Category.管段),
|
||||
WarehouseCode = PipelineService.GetPipeArea().Where(x => x.Value == PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).PipeArea).Select(x => x.Text).FirstOrDefault(),
|
||||
Source = 1,
|
||||
InOutType = (int)TwConst.InOutType.出库,
|
||||
TypeInt = (int)TwConst.TypeInt.领料出库,
|
||||
State = (int)TwConst.State.待审核,
|
||||
Category = (int)TwConst.Category.管段,
|
||||
CreateMan = Personid,
|
||||
CreateDate = DateTime.Now,
|
||||
WeldTaskId = WeldTaskId,
|
||||
ReqUnitId = weldTask.UnitId,
|
||||
};
|
||||
TwInOutplanmasterService.Add(table);
|
||||
foreach (var item in outPlanDetailListOthere)
|
||||
{
|
||||
Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = table.Id,
|
||||
MaterialCode = item.MaterialCode,
|
||||
PlanNum = item.planNum,
|
||||
};
|
||||
TwInOutplandetailService.Add(detail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user