Merge branch 'master' of https://gitee.com/frane-yang/SGGL_SeDin_New
This commit is contained in:
@@ -1467,6 +1467,37 @@ namespace BLL
|
||||
return "";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 将List 中的数据平均拆分为多个List
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="originalList">原始List</param>
|
||||
/// <param name="numberOfLists">拆分后的子列表数量</param>
|
||||
/// <returns></returns>
|
||||
/**们首先计算出每个子列表的大小chunkSize和余数remainder。然后,使用一个循环来创建并添加子列表到splitLists中。
|
||||
|
||||
在每次迭代中,我们根据当前索引是否小于余数来确定子列表的大小。如果小于余数,则将子列表大小加1,以确保最后一个子列表包含余数部分。
|
||||
|
||||
最后,我们更新startIndex以便正确获取下一个子列表的元素范围*/
|
||||
public static List<List<T>> SplitList<T>(List<T> originalList, int numberOfLists)
|
||||
{
|
||||
List<List<T>> splitLists = new List<List<T>>();
|
||||
int chunkSize = originalList.Count / numberOfLists;
|
||||
int remainder = originalList.Count % numberOfLists;
|
||||
|
||||
int startIndex = 0;
|
||||
for (int i = 0; i < numberOfLists; i++)
|
||||
{
|
||||
int sublistSize = chunkSize + (i < remainder ? 1 : 0);
|
||||
List<T> sublist = originalList.GetRange(startIndex, sublistSize);
|
||||
splitLists.Add(sublist);
|
||||
|
||||
startIndex += sublistSize;
|
||||
}
|
||||
|
||||
return splitLists;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
using Model;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -12,16 +15,21 @@ namespace BLL
|
||||
/// 未验收
|
||||
/// </summary>
|
||||
public static int state_0 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 已验收
|
||||
/// </summary>
|
||||
public static int state_1 = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 已装箱
|
||||
/// </summary>
|
||||
public static int state_2 = 2;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取状态名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ListItem[] GetState()
|
||||
{
|
||||
ListItem[] list = new ListItem[3];
|
||||
@@ -30,6 +38,10 @@ namespace BLL
|
||||
list[2] = new ListItem("已出库", state_2.ToString());
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ListItem[] GetProductionState()
|
||||
{
|
||||
ListItem[] list = new ListItem[3];
|
||||
@@ -61,6 +73,81 @@ namespace BLL
|
||||
{
|
||||
return Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipeLineMatId == pipeLineMatId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打印实体
|
||||
/// </summary>
|
||||
/// <param name="PipelineComponentId"></param>
|
||||
/// <param name="PipelineId"></param>
|
||||
/// <param name="IsCheckPrint"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<PipelineComponentPrintDto> GetPrintModelByPipelineComponentIds(
|
||||
string[] PipelineComponentId, string[] PipelineId, bool IsCheckPrint)
|
||||
{
|
||||
var db = Funs.DB;
|
||||
var query =
|
||||
from com in db.HJGL_Pipeline_Component
|
||||
|
||||
join mat in db.HJGL_PipeLineMat on com.PipeLineMatId equals mat.PipeLineMatId into matJoin
|
||||
|
||||
from mat in matJoin.DefaultIfEmpty()
|
||||
join pipe in db.HJGL_Pipeline on com.PipelineId equals pipe.PipelineId into pipeJoin
|
||||
|
||||
from pipe in pipeJoin.DefaultIfEmpty()
|
||||
join punit in db.Base_Unit on com.PreUnit equals punit.UnitId into punitJoin
|
||||
|
||||
from punit in punitJoin.DefaultIfEmpty()
|
||||
join aunit in db.Base_Unit on com.AssembleUnit equals aunit.UnitId into aunitJoin
|
||||
|
||||
from aunit in aunitJoin.DefaultIfEmpty()
|
||||
join unitwork in db.WBS_UnitWork on pipe.UnitWorkId equals unitwork.UnitWorkId into unitworkJoin
|
||||
|
||||
from unitwork in unitworkJoin.DefaultIfEmpty()
|
||||
join mater in db.Base_Material on pipe.MaterialId equals mater.MaterialId into materJoin
|
||||
|
||||
from mater in materJoin.DefaultIfEmpty()
|
||||
where com.QRCode != ""
|
||||
orderby com.PipelineComponentCode,com.PipelineId
|
||||
|
||||
select new PipelineComponentPrintDto
|
||||
{
|
||||
PipelineComponentId = com.PipelineComponentId,
|
||||
PipelineComponentCode = com.PipelineComponentCode,
|
||||
BoxNumber = com.BoxNumber,
|
||||
UnitWorkName = unitwork.UnitWorkName,
|
||||
PipelineId = com.PipelineId,
|
||||
PreUnit = punit.UnitName,
|
||||
AssembleUnit = aunit.UnitName,
|
||||
PrefabricatedComponents = mat.PrefabricatedComponents,
|
||||
QRCode = com.QRCode,
|
||||
State = com.State,
|
||||
PlanStartDate = string.Format("yyyy-MM-dd", pipe.PlanStartDate),
|
||||
PipelineCode = pipe.PipelineCode,
|
||||
FlowingSection = pipe.FlowingSection,
|
||||
QRCode2 = "PrePipeline$" + com.PipelineComponentId,
|
||||
MaterialCode = mater.MaterialCode,
|
||||
IsPrint = com.IsPrint
|
||||
|
||||
};
|
||||
var result = query.ToList();
|
||||
if (PipelineComponentId!=null &&PipelineComponentId.Length > 0)
|
||||
{
|
||||
result = result.Where(x => PipelineComponentId.Contains(x.PipelineComponentId.ToString())).ToList();
|
||||
}
|
||||
if (PipelineId != null && PipelineId.Length > 0)
|
||||
{
|
||||
result = result.Where(x => PipelineId.Contains(x.PipelineId.ToString())).ToList();
|
||||
}
|
||||
|
||||
if (IsCheckPrint != null & IsCheckPrint ==true)
|
||||
{
|
||||
result = result.Where(x => x.IsPrint==false||x.IsPrint==null).ToList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断管线组件Code是否存在
|
||||
/// </summary>
|
||||
@@ -119,6 +206,7 @@ namespace BLL
|
||||
model.DrawingName = model_mat.PrefabricatedComponents.Substring(0, model_mat.PrefabricatedComponents.LastIndexOf('-')).Replace("\"", "");
|
||||
model.State = state_0;
|
||||
model.ProductionState = 0;
|
||||
model.IsPrint = false;
|
||||
AddPipelineComponent(model);
|
||||
}
|
||||
|
||||
@@ -133,6 +221,7 @@ namespace BLL
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.HJGL_Pipeline_Component newPipeline = new Model.HJGL_Pipeline_Component();
|
||||
pipeline.IsPrint ??= false;
|
||||
newPipeline.PipelineComponentId = pipeline.PipelineComponentId;
|
||||
newPipeline.PipelineId = pipeline.PipelineId;
|
||||
newPipeline.PreUnit = pipeline.PreUnit;
|
||||
@@ -150,6 +239,7 @@ namespace BLL
|
||||
newPipeline.ReceiveMan= pipeline.ReceiveMan;
|
||||
newPipeline.ReceiveDate= pipeline.ReceiveDate;
|
||||
newPipeline.ProductionState= pipeline.ProductionState;
|
||||
newPipeline.IsPrint= pipeline.IsPrint;
|
||||
db.HJGL_Pipeline_Component.InsertOnSubmit(newPipeline);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
@@ -180,10 +270,15 @@ namespace BLL
|
||||
newPipeline.ReceiveMan = pipeline.ReceiveMan;
|
||||
newPipeline.ReceiveDate = pipeline.ReceiveDate;
|
||||
newPipeline.ProductionState = pipeline.ProductionState;
|
||||
|
||||
newPipeline.IsPrint=pipeline.IsPrint;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改出库状态
|
||||
/// </summary>
|
||||
/// <param name="pipelineComponentId"></param>
|
||||
/// <param name="BoxNumber"></param>
|
||||
public static void UpdateOutState(string pipelineComponentId,string BoxNumber)
|
||||
{
|
||||
var q=GetPipelineComponentById(pipelineComponentId);
|
||||
@@ -196,6 +291,24 @@ namespace BLL
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改打印状态
|
||||
/// </summary>
|
||||
/// <param name="PipelineComponentId"></param>
|
||||
public static void UpdateIsPrint(string[] PipelineComponentId)
|
||||
{
|
||||
var componentsToUpdate = Funs.DB.HJGL_Pipeline_Component
|
||||
|
||||
.Where(c => PipelineComponentId.Contains(c.PipelineComponentId));
|
||||
|
||||
foreach (var component in componentsToUpdate)
|
||||
{
|
||||
component.IsPrint = true;
|
||||
}
|
||||
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改生产状态
|
||||
/// </summary>
|
||||
@@ -345,4 +458,26 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PipelineComponentPrintDto
|
||||
|
||||
{
|
||||
public string PipelineComponentId { get; set; }
|
||||
public string PipelineComponentCode { get; set; }
|
||||
public string BoxNumber { get; set; }
|
||||
public string UnitWorkName { get; set; }
|
||||
public string PipelineId { get; set; }
|
||||
public string PreUnit { get; set; }
|
||||
public string AssembleUnit { get; set; }
|
||||
public string PrefabricatedComponents { get; set; }
|
||||
public string QRCode { get; set; }
|
||||
public int? State { get; set; }
|
||||
public string PlanStartDate { get; set; }
|
||||
public string PipelineCode { get; set; }
|
||||
public string FlowingSection { get; set; }
|
||||
public string QRCode2 { get; set; }
|
||||
public string MaterialCode { get; set; }
|
||||
public bool? IsPrint { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EmitMapper;
|
||||
using EmitMapper.MappingConfiguration;
|
||||
using FineUIPro;
|
||||
@@ -168,7 +169,6 @@ namespace BLL
|
||||
return Funs.DB.PHTGL_ContractTrack.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
|
||||
public static void AddPHTGL_ContractTrack(PHTGL_ContractTrack newtable)
|
||||
{
|
||||
var table = new PHTGL_ContractTrack
|
||||
@@ -209,7 +209,14 @@ namespace BLL
|
||||
PhtglContracttrackprogressService.CreateTemplateByContractTrackId(newtable.Id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void AddBulkPHTGL_ContractTrack(List<PHTGL_ContractTrack> list)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
db.PHTGL_ContractTrack.InsertAllOnSubmit(list);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void UpdatePHTGL_ContractTrack(PHTGL_ContractTrack newtable)
|
||||
@@ -352,12 +359,13 @@ namespace BLL
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<PHTGL_ContractTrackDtoIn> rows;
|
||||
List<PHTGL_ContractTrack> thisContractTracks =new List<PHTGL_ContractTrack>();
|
||||
|
||||
var sheetNames = MiniExcel.GetSheetNames(path);
|
||||
foreach (var sheet in sheetNames) ////多sheet导入
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
rows = MiniExcel.Query<PHTGL_ContractTrackDtoIn>(path, sheetName: sheet,startCell:"A2").ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -370,6 +378,7 @@ namespace BLL
|
||||
ObjectMapperManager.DefaultInstance.GetMapper<List<PHTGL_ContractTrackDtoIn>, List<PHTGL_ContractTrack>>();
|
||||
var modeList = mapper.Map(rows);
|
||||
|
||||
List<PHTGL_ContractTrack> goingAddList = new List<PHTGL_ContractTrack>();
|
||||
if (modeList.Count == 0)
|
||||
{
|
||||
responeData.code = 0;
|
||||
@@ -388,25 +397,31 @@ namespace BLL
|
||||
ContractId = contractid,
|
||||
ProjectId = projectid,
|
||||
};
|
||||
var resultModel = GetPHTGL_ContractTrackByModle(phtglContractTrack);
|
||||
var resultModel = GetFirstPHTGL_ContractTrackByModle(phtglContractTrack);
|
||||
item.ContractNum = ContractService.GetContractById(contractid)?.ContractNum;
|
||||
if (!string.IsNullOrEmpty(item.ProjectCode) && !item.ProjectCode.Contains("-"))
|
||||
{
|
||||
|
||||
item.ProjectCode = item.MainItemCode + "-" + item.ProjectCode;
|
||||
}
|
||||
if (resultModel.Any())
|
||||
|
||||
if (resultModel!=null)
|
||||
{
|
||||
item.Id = resultModel[0].Id;
|
||||
item.Id = resultModel.Id;
|
||||
UpdatePHTGL_ContractTrack(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Id = SQLHelper.GetNewID();
|
||||
AddPHTGL_ContractTrack(item);
|
||||
goingAddList.Add(item);
|
||||
//AddPHTGL_ContractTrack(item);
|
||||
}
|
||||
PhtglContracttrackprogressService.CreateTemplateByContractTrackId(item.Id);
|
||||
thisContractTracks.Add(item);
|
||||
//PhtglContracttrackprogressService.CreateTemplateByContractTrackId(item.Id);
|
||||
}
|
||||
|
||||
AddBulkPHTGL_ContractTrack(goingAddList);
|
||||
PhtglContracttrackprogressService.CreateTemplateByContractList(goingAddList,projectid);
|
||||
}
|
||||
|
||||
return responeData;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
|
||||
@@ -17,8 +19,7 @@ namespace BLL
|
||||
/// </summary>
|
||||
public static int Count { get; set; }
|
||||
|
||||
public static List<PHTGL_ContractTrackProgress> GetPHTGL_ContractTrackProgressByModle(
|
||||
PHTGL_ContractTrackProgress table)
|
||||
public static IQueryable<PHTGL_ContractTrackProgress> GetPHTGL_ContractTrackProgressByModle( PHTGL_ContractTrackProgress table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_ContractTrackProgress
|
||||
where
|
||||
@@ -31,10 +32,23 @@ namespace BLL
|
||||
orderby x.Date
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
return q;
|
||||
}
|
||||
public static PHTGL_ContractTrackProgress GetFirstOrDefaultByModle(PHTGL_ContractTrackProgress table)
|
||||
{
|
||||
var q = (from x in Funs.DB.PHTGL_ContractTrackProgress
|
||||
where
|
||||
(string.IsNullOrEmpty(table.ContractTrackProgressId) ||
|
||||
x.ContractTrackProgressId.Contains(table.ContractTrackProgressId)) &&
|
||||
(string.IsNullOrEmpty(table.ContractTrackId) ||
|
||||
x.ContractTrackId.Contains(table.ContractTrackId)) &&
|
||||
(string.IsNullOrEmpty(table.Date) ||
|
||||
x.Date.Contains(table.Date))
|
||||
orderby x.Date
|
||||
select x).FirstOrDefault()
|
||||
;
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
@@ -46,7 +60,7 @@ namespace BLL
|
||||
var q = GetPHTGL_ContractTrackProgressByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0) return null;
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
||||
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 new
|
||||
@@ -98,6 +112,7 @@ namespace BLL
|
||||
ContractTrackId = ContractTrackId,
|
||||
Date= month.ToString("yyyy-MM")
|
||||
};
|
||||
|
||||
if (!GetPHTGL_ContractTrackProgressByModle(querymodel).Any())
|
||||
{
|
||||
var newmodel = new Model.PHTGL_ContractTrackProgress();
|
||||
@@ -110,6 +125,75 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void CreateTemplateByContractList(List<PHTGL_ContractTrack> contractTrackList,string projectid)
|
||||
{
|
||||
var dbcontractTrack=(from x in Funs.DB.PHTGL_ContractTrack where x.ProjectId==projectid select x).ToList();
|
||||
var dbContractTrackProgress=(from x in Funs.DB.PHTGL_ContractTrackProgress
|
||||
join y in Funs.DB.PHTGL_ContractTrack on x.ContractTrackId equals y.Id
|
||||
where y.ProjectId==projectid select x).ToList();
|
||||
|
||||
List<List<PHTGL_ContractTrack>> splitLists = new List<List<PHTGL_ContractTrack>>();
|
||||
if (contractTrackList.Count>10)
|
||||
{
|
||||
splitLists = Funs.SplitList(contractTrackList, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
splitLists = Funs.SplitList(contractTrackList, 1);
|
||||
}
|
||||
ConcurrentBag<PHTGL_ContractTrackProgress> contractTrackProgressList = new ConcurrentBag<PHTGL_ContractTrackProgress>();//用于批量新增的数据
|
||||
|
||||
ParallelOptions parallelOptions = new ParallelOptions();
|
||||
parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount;
|
||||
|
||||
Parallel.ForEach(splitLists, parallelOptions, sublist =>
|
||||
{
|
||||
|
||||
foreach (var item in sublist)
|
||||
{
|
||||
var model =( from x in dbcontractTrack where x.Id==item.Id select x).FirstOrDefault() ;
|
||||
if (model == null) return;
|
||||
var contractNum = model.ContractNum;
|
||||
var contractmode = ContractService.GetContractByContractNum(contractNum);
|
||||
if (contractmode.ContractStartDate != null && contractmode.ContractEndDate != null)
|
||||
{
|
||||
var startDate = (DateTime)contractmode.ContractStartDate;
|
||||
var endDate = (DateTime)contractmode.ContractEndDate;
|
||||
List<DateTime> months = GetMonthsBetween(startDate, endDate);//获取合同起止日期
|
||||
|
||||
foreach (DateTime month in months)
|
||||
{
|
||||
var querymodel = new Model.PHTGL_ContractTrackProgress
|
||||
{
|
||||
ContractTrackId = item.Id,
|
||||
Date = month.ToString("yyyy-MM")
|
||||
};
|
||||
var q = (from x in dbContractTrackProgress
|
||||
where
|
||||
(string.IsNullOrEmpty(querymodel.ContractTrackId) ||
|
||||
x.ContractTrackId.Contains(querymodel.ContractTrackId)) &&
|
||||
(string.IsNullOrEmpty(querymodel.Date) ||
|
||||
x.Date.Contains(querymodel.Date))
|
||||
orderby x.Date
|
||||
select x).ToList()
|
||||
;
|
||||
if (!q.Any())
|
||||
{
|
||||
var newmodel = new Model.PHTGL_ContractTrackProgress();
|
||||
newmodel.ContractTrackProgressId = SQLHelper.GetNewID(typeof(Model.PHTGL_ContractTrackProgress));
|
||||
newmodel.ContractTrackId = item.Id;
|
||||
newmodel.Date = month.ToString("yyyy-MM");
|
||||
contractTrackProgressList.Add(newmodel);
|
||||
// AddPHTGL_ContractTrackProgress(newmodel);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // 处理完成后,可以将结果保存到集合或其他地方
|
||||
|
||||
});
|
||||
|
||||
AddBulkPHTGL_ContractTrackProgress(contractTrackProgressList.ToList());
|
||||
}
|
||||
|
||||
public static List<DateTime> GetMonthsBetween(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
@@ -145,6 +229,12 @@ namespace BLL
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void AddBulkPHTGL_ContractTrackProgress(List<PHTGL_ContractTrackProgress> newtableList)
|
||||
{
|
||||
Funs.DB.PHTGL_ContractTrackProgress.InsertAllOnSubmit(newtableList);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdatePHTGL_ContractTrackProgress(PHTGL_ContractTrackProgress newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_ContractTrackProgress.FirstOrDefault(x =>
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace BLL
|
||||
var pUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(e => e.ProjectId == ProjectId && e.UnitId == PersonEntity.UnitId);
|
||||
if (pUnit != null)
|
||||
{
|
||||
if (pUnit.UnitType == Const.ProjectUnitType_1 )
|
||||
if (pUnit.UnitType == Const.ProjectUnitType_1 || pUnit.UnitType == Const.ProjectUnitType_2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user