提交代码
This commit is contained in:
@@ -0,0 +1,252 @@
|
||||
using Model;
|
||||
using Model.APIItem;
|
||||
using NPOI.SS.Formula.Eval;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class APIQuantityManagementService
|
||||
{
|
||||
public static Model.ResponeData DayInputList(string projectId, string drawingNo, string part, string projectContent, int page, int pageSize)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = from x in db.View_QuantityManagement_DayInputList where x.ProjectId == projectId select x;
|
||||
if (!string.IsNullOrEmpty(drawingNo))
|
||||
{
|
||||
q = q.Where(x => x.DrawingNo.Contains(drawingNo));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(part))
|
||||
{
|
||||
q = q.Where(x => x.Part.Contains(part));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(projectContent))
|
||||
{
|
||||
q = q.Where(x => x.ProjectContent.Contains(projectContent));
|
||||
}
|
||||
List<DayInputItem> dayInputItems = new List<DayInputItem>();
|
||||
var list = q.OrderByDescending(x => x.Date).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
foreach (var x in list)
|
||||
{
|
||||
DayInputItem dayInputItem = new DayInputItem();
|
||||
dayInputItem.DayInputId = x.DayInputId;
|
||||
dayInputItem.ProjectId = x.ProjectId;
|
||||
dayInputItem.WorkSection = x.WorkSection;
|
||||
dayInputItem.DrawingNo = x.DrawingNo;
|
||||
dayInputItem.DrawingName = x.DrawingName;
|
||||
dayInputItem.Part = x.Part;
|
||||
dayInputItem.ProjectContent = x.ProjectContent;
|
||||
dayInputItem.Unit = x.Unit;
|
||||
dayInputItem.Amount = x.Amount;
|
||||
dayInputItem.WorkTeam = x.WorkTeam;
|
||||
dayInputItem.Date = x.Date;
|
||||
if (x.Date != null)
|
||||
{
|
||||
dayInputItem.DateStr = string.Format("{0:yyyy-MM-dd}", x.Date);
|
||||
}
|
||||
dayInputItem.DayAmount = x.DayAmount;
|
||||
dayInputItems.Add(dayInputItem);
|
||||
}
|
||||
}
|
||||
dayInputItems = dayInputItems.Skip(page * pageSize).Take(pageSize).ToList();
|
||||
respone.data = dayInputItems;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData getDayInputById(string dayInputId)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
View_QuantityManagement_DayInputList dayInput = (from x in db.View_QuantityManagement_DayInputList where x.DayInputId == dayInputId select x).FirstOrDefault();
|
||||
|
||||
DayInputItem dayInputItem = new DayInputItem();
|
||||
dayInputItem.DayInputId = dayInput.DayInputId;
|
||||
dayInputItem.ProjectId = dayInput.ProjectId;
|
||||
dayInputItem.WorkSection = dayInput.WorkSection;
|
||||
dayInputItem.DrawingId = dayInput.DrawingId;
|
||||
dayInputItem.DrawingNo = dayInput.DrawingNo;
|
||||
dayInputItem.DrawingName = dayInput.DrawingName;
|
||||
dayInputItem.Part = dayInput.Part;
|
||||
dayInputItem.ProjectContent = dayInput.ProjectContent;
|
||||
dayInputItem.Unit = dayInput.Unit;
|
||||
dayInputItem.Amount = dayInput.Amount;
|
||||
dayInputItem.WorkTeam = dayInput.WorkTeam;
|
||||
dayInputItem.WorkTeamId = dayInput.WorkTeamId;
|
||||
dayInputItem.Date = dayInput.Date;
|
||||
if (dayInput.Date != null)
|
||||
{
|
||||
dayInputItem.DateStr = string.Format("{0:yyyy-MM-dd}", dayInput.Date);
|
||||
}
|
||||
dayInputItem.DayAmount = dayInput.DayAmount;
|
||||
var file = db.AttachFile.FirstOrDefault(x => x.ToKeyId == dayInput.DayInputId);
|
||||
if (file != null)
|
||||
{
|
||||
dayInputItem.Url = file.AttachUrl;
|
||||
}
|
||||
respone.data = dayInputItem;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData addDayInput(DayInputItem dayInput)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
QuantityManagement_DayInput newDayInput = new QuantityManagement_DayInput();
|
||||
if (string.IsNullOrEmpty(dayInput.DayInputId))
|
||||
{
|
||||
newDayInput.DayInputId = Guid.NewGuid().ToString();
|
||||
db.QuantityManagement_DayInput.InsertOnSubmit(newDayInput);
|
||||
}
|
||||
else
|
||||
{
|
||||
newDayInput = db.QuantityManagement_DayInput.FirstOrDefault(x => x.DayInputId == dayInput.DayInputId);
|
||||
}
|
||||
newDayInput.ProjectId = dayInput.ProjectId;
|
||||
newDayInput.BaseId = dayInput.BaseId;
|
||||
newDayInput.Date = Funs.GetNewDateTimeOrNow(dayInput.DateStr);
|
||||
newDayInput.DayAmount = Funs.GetNewDecimal(dayInput.DayAmount.ToString());
|
||||
newDayInput.WorkTeam = dayInput.WorkTeamId;
|
||||
newDayInput.CompileMan = dayInput.CompileMan;
|
||||
newDayInput.CompileDate = DateTime.Now;
|
||||
db.SubmitChanges();
|
||||
SaveUrl(dayInput.DayInputId, BLL.Const.DayInputMenuId, dayInput.Url);
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static void SaveUrl(string dayInputId, string menuId, string url)
|
||||
{
|
||||
Model.ToDoItem toDoItem = new Model.ToDoItem
|
||||
{
|
||||
MenuId = menuId,
|
||||
DataId = dayInputId,
|
||||
UrlStr = url,
|
||||
};
|
||||
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
||||
}
|
||||
|
||||
public static Model.ResponeData getDrawingNoList(string projectId)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = BLL.DrawingService.GetDrawingChangeListByProjectId(projectId);
|
||||
List<DrawingItem> res = new List<DrawingItem>();
|
||||
foreach (var p in q)
|
||||
{
|
||||
DrawingItem item = new DrawingItem();
|
||||
item.DrawingId = p.Value;
|
||||
item.DrawingNo = p.Text;
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
respone.data = res;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData getTeamGroupList(string projectId)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = from x in db.ProjectData_TeamGroup
|
||||
where x.ProjectId == projectId
|
||||
orderby x.TeamGroupCode
|
||||
select x;
|
||||
List<TeamGroupItem> res = new List<TeamGroupItem>();
|
||||
foreach (var p in q)
|
||||
{
|
||||
TeamGroupItem item = new TeamGroupItem();
|
||||
item.TeamGroupId = p.TeamGroupId;
|
||||
item.TeamGroupName = p.TeamGroupName;
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
respone.data = res;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData getPartList(string drawingId)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = (from x in db.QuantityManagement_Base
|
||||
where x.DrawingId == drawingId && x.State == BLL.Const.Base_Complete
|
||||
orderby x.Part
|
||||
select x.Part).Distinct().ToList();
|
||||
List<BaseInfoItem> res = new List<BaseInfoItem>();
|
||||
foreach (var p in q)
|
||||
{
|
||||
BaseInfoItem item = new BaseInfoItem();
|
||||
item.BaseInfoId = p;
|
||||
item.BaseInfoName = p;
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
respone.data = res;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData getProjectContentList(string drawingId, string part)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = (from x in db.QuantityManagement_Base
|
||||
where x.DrawingId == drawingId && x.Part == part && x.State == BLL.Const.Base_Complete
|
||||
orderby x.ProjectContent
|
||||
select x).ToList();
|
||||
List<BaseInfoItem> res = new List<BaseInfoItem>();
|
||||
foreach (var p in q)
|
||||
{
|
||||
BaseInfoItem item = new BaseInfoItem();
|
||||
item.BaseInfoId = p.BaseId;
|
||||
item.BaseInfoName = p.ProjectContent;
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
respone.data = res;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
|
||||
public static Model.ResponeData getBase(string baseId)
|
||||
{
|
||||
Model.ResponeData respone = new ResponeData();
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = db.QuantityManagement_Base.FirstOrDefault(e => e.BaseId == baseId);
|
||||
BaseInfoItem res = new BaseInfoItem();
|
||||
if (q != null)
|
||||
{
|
||||
decimal usedAmount = (from x in db.QuantityManagement_DayInput where x.BaseId == baseId select x).ToList().Sum(x => x.DayAmount ?? 0);
|
||||
if (q.Amount != null)
|
||||
{
|
||||
res.Remark = q.Unit;
|
||||
res.Amount = q.Amount - usedAmount;
|
||||
res.BaseInfoId = q.WorkTeam;
|
||||
}
|
||||
}
|
||||
|
||||
respone.data = res;
|
||||
}
|
||||
return respone;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user