You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
223 lines
7.9 KiB
223 lines
7.9 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Net;
|
|
using System.IO;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace NFine.Application.OMAY
|
|
{
|
|
public class OMAYApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public DataTable GetYLAndPC(string Type ,string Group, string TimeFrom, string TimeArrive)
|
|
{
|
|
string sql = @"select
|
|
isnull( sum( case when c.BusinessCode='13' and SUBSTRING(b.InvCode, 1, 2) IN ('01','04','05') then isnull(c.Quantity,0) else 0 end ),0) as YLTR ,
|
|
isnull( sum( case when c.BusinessCode='50' and b.EATTRIBUTE1='1' and SUBSTRING(b.InvCode, 1, 2) IN ('05') then isnull(c.Quantity,0) else 0 end) ,0)as PCLRK
|
|
from dbo.ICSMO a
|
|
inner join dbo.ICSMOPick b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
|
|
inner join dbo.ICSWareHouseLotInfoLog c on a.MOCode=c.TransCode and a.Sequence+'~'+b.Sequence=c.TransSequence
|
|
inner join dbo.ICSDepartment d on a.DepCode=d.DepCode
|
|
where d.DepName = '" + Type + "' and c.MUSERName= '" + Type + Group + "' ";
|
|
if (!string.IsNullOrWhiteSpace(TimeFrom))
|
|
{
|
|
sql += "and left(c.MTIME,7)>='" + TimeFrom + "'";
|
|
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(TimeArrive))
|
|
{
|
|
sql += "and left(c.MTIME,7)<='" + TimeArrive + "'";
|
|
}
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
public DataTable GetCC(string Type, string Group, string TimeFrom, string TimeArrive)
|
|
{
|
|
|
|
string sql = @" select isnull( sum(isnull(b.Quantity,0)),0) as CC
|
|
from dbo.ICSMO a
|
|
inner join dbo.ICSWareHouseLotInfoLog b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and b.BusinessCode='17'
|
|
inner join dbo.ICSDepartment d on a.DepCode=d.DepCode
|
|
where d.DepName = '" + Type + "' and b.MUSERName= '" + Type + Group + "' ";
|
|
if (!string.IsNullOrWhiteSpace(TimeFrom))
|
|
{
|
|
sql += "and left(b.MTIME,7)>='" + TimeFrom + "'";
|
|
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(TimeArrive))
|
|
{
|
|
sql += "and left(b.MTIME,7)<='" + TimeArrive + "'";
|
|
}
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
public string CreateKPIMaintain(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"IF EXISTS(SELECT * FROM dbo.ICSKPIMaintain
|
|
where Team = '{0}' and Date='{1}' and WorkPoint='{5}')
|
|
BEGIN
|
|
RAISERROR('班组:{0},已维护过{1}信息!',16,1);
|
|
RETURN
|
|
END
|
|
INSERT INTO dbo.ICSKPIMaintain
|
|
( ID ,Team,Date,Metrics ,Picking ,CreatePerson,CreateDate,MUSER,MTIME,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{4}',GETDATE(),'{5}')
|
|
";
|
|
sql = string.Format(sql, queryParam["Team"].ToString(), queryParam["Date"].ToString(), queryParam["Metrics"].ToString(), queryParam["Picking"].ToString(), MUSER, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string UpdateKPIMaintain(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSKPIMaintain set Team = '{0}',Date='{1}',Metrics='{2}',Picking='{3}',MTIME=GETDATE(),MUSER='{4}',WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["Team"].ToString(), queryParam["Date"].ToString(), queryParam["Metrics"].ToString(), queryParam["Picking"].ToString(), MUSER, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string DeleteOMAYMaintain(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = string.Format(@"DELETE FROM dbo.ICSKPIMaintain WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetZB(string TimeFrom, string TimeArrive)
|
|
{
|
|
var Condition = "";
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"CREATE TABLE #TempTable(Team VARCHAR(50))
|
|
INSERT INTO #TempTable ( Team)
|
|
VALUES ( 'L1'),('L2'), ( 'L3'), ('L4'),('L5'), ('L6');
|
|
|
|
select a.Team as Team, isnull(sum(cast(b.Metrics as decimal)),0) as Metrics
|
|
from #TempTable a left join ICSKPIMaintain b on a.Team=SUBSTRING(b.Team, 1, 2) {0}
|
|
group by a.Team
|
|
|
|
drop table #TempTable";
|
|
|
|
if (!string.IsNullOrWhiteSpace(TimeFrom))
|
|
{
|
|
Condition += "and b.Date>='"+ TimeFrom + "'";
|
|
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(TimeArrive))
|
|
{
|
|
Condition += "and b.Date<='" + TimeArrive + "'";
|
|
}
|
|
sql= string.Format(sql, Condition);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetYFFJ(string TimeFrom, string TimeArrive)
|
|
{
|
|
var Condition = "";
|
|
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"CREATE TABLE #TempTable(Team VARCHAR(50))
|
|
INSERT INTO #TempTable ( Team)
|
|
VALUES ( 'L1A'),( 'L1B'),( 'L2A'),( 'L2B'),( 'L3A'),( 'L3B'), ( 'L4A'),( 'L4B'), ( 'L5A'),( 'L5B'),( 'L6A'),( 'L6B')
|
|
|
|
select a.Team as Team,isnull(cast(b.Picking as decimal),0) as Picking
|
|
from #TempTable a left join ICSKPIMaintain b on a.Team=b.Team {0}
|
|
|
|
|
|
drop table #TempTable";
|
|
if (!string.IsNullOrWhiteSpace(TimeFrom))
|
|
{
|
|
Condition += "and b.Date>='" + TimeFrom + "'";
|
|
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(TimeArrive))
|
|
{
|
|
Condition += "and b.Date<='" + TimeArrive + "'";
|
|
}
|
|
sql = string.Format(sql, Condition);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|