sql.AppendLine(" INSERT INTO T_AW_COMPLETE_STATISTICS ");
sql.AppendLine(" INSERT INTO T_AW_COMPLETE_STATISTICS SELECT NEWID(),MATERIALNO AS MATERIALNO,COUNT(MATERIALNO) AS SYSCOMPLETECOUNT,COUNT(MATERIALNO) AS COMPLETECOUNT, ");
sql.AppendLine(" SELECT NEWID(),");
sql.AppendLine(" C.MFG_MATERIAL_CODE AS MATERIALNO,");
sql.AppendLine(" REPLICATE('0', 2 - LEN(ROW_NUMBER() OVER (ORDER BY C.MFG_MATERIAL_CODE))) + CAST (ROW_NUMBER() OVER (ORDER BY C.MFG_MATERIAL_CODE) AS VARCHAR) AS ORDERNO, ");
sql.AppendLine(" GETDATE() AS CREATETIME, ");
sql.AppendLine(" USR.USERID AS CREATEUSER, ");
sql.AppendLine(" GETDATE() AS UPDATETIME, ");
sql.AppendLine(" USR.USERID AS UPDATEUSER, ");
sql.AppendLine(" '0' AS DELFLAG ");
sql.AppendLine(" FROM T_AW_PRODUCT T ");
sql.AppendLine(" LEFT JOIN T_MD_MATERIAL_CLASS S ON S.MATERIAL_TYPE_CODE=T.MATERIAL_TYPE ");
sql.AppendLine(" LEFT JOIN T_AW_COMPLETE_MFG_CONFIG C ON C.MES_MATERIAL_CODE = T.MATERIAL_CODE ");
sql.AppendLine(" LEFT JOIN T_QM_USER USR ");
sql.AppendLine(" ON USR.USERNAME = 'SYSTEM' ");
sql.AppendLine(" WHERE S.MATERIAL_ATTRIBUTE='2' ");
sql.AppendLine(" AND C.MFG_MATERIAL_CODE IS NOT NULL ");
sql.AppendLine(" AND T.CREATEDATE > @StartTime ");
sql.AppendLine(" AND T.CREATEDATE <= @EndTime ");
sql.AppendLine(" AND T.MACHINECODDE IS NOT NULL ");
sql.AppendLine(" GROUP BY C.MFG_MATERIAL_CODE, USR.USERID, C.ORDERIDENTITY ");
returnsql.ToString();
}
//天津770发运 MFG回冲
protectedstringGetFrmPlaceStatisticsSql()
{
StringBuildersql=newStringBuilder();
sql.AppendLine(" INSERT INTO T_AW_COMPLETE_STATISTICS ");
sql.AppendLine(" SELECT NEWID(),");
sql.AppendLine(" C.MFG_MATERIAL_CODE AS MATERIALNO,");
sql.AppendLine(" COUNT(*) AS SYSCOMPLETECOUNT,");
sql.AppendLine(" COUNT(*) AS COMPLETECOUNT,");
sql.AppendLine(" @StartTime AS STARTTIME,");
sql.AppendLine(" @StartTime AS STARTTIME,");
sql.AppendLine(" @EndTime AS ENDTIME,");
sql.AppendLine(" @EndTime AS ENDTIME,");
sql.AppendLine(" C.ORDERIDENTITY + ");
sql.AppendLine(" CASE MAX(line) WHEN '770B' THEN 'DP20' ELSE MAX(line) END AS ORDERNO, ");
sql.AppendLine(" REPLICATE('0', 2 - LEN(ROW_NUMBER() OVER (ORDER BY C.MFG_MATERIAL_CODE))) + CAST (ROW_NUMBER() OVER (ORDER BY C.MFG_MATERIAL_CODE) AS VARCHAR) AS ORDERNO, ");
sql.AppendLine(" GETDATE() AS CREATETIME,");
sql.AppendLine(" GETDATE() AS CREATETIME,");
sql.AppendLine(" USR.USERID AS CREATEUSER, ");
sql.AppendLine(" 'b5c45b3e-724e-4d92-aad0-ef0cf3422a9e' AS CREATEUSER,");
sql.AppendLine(" GETDATE() AS UPDATETIME,");
sql.AppendLine(" GETDATE() AS UPDATETIME,");
sql.AppendLine(" USR.USERID AS UPDATEUSER, ");
sql.AppendLine(" 'b5c45b3e-724e-4d92-aad0-ef0cf3422a9e' AS UPDATEUSER,");
sql.AppendLine(" '0' AS DELFLAG");
sql.AppendLine(" '0' AS DELFLAG");
sql.AppendLine(" FROM T_AW_PRODUCT T ");
sql.AppendLine(" FROM T_AW_COMPLETE_TJSTATISTICS T");
sql.AppendLine(" LEFT JOIN T_MD_MATERIAL_CLASS S ON S.MATERIAL_TYPE_CODE=T.MATERIAL_TYPE ");
sql.AppendLine(" WHERE T.DELFLAG ='0' ");
sql.AppendLine(" LEFT JOIN T_AW_COMPLETE_MFG_CONFIG C ON C.MES_MATERIAL_CODE = T.MATERIAL_CODE ");
sql.AppendLine(" AND T.ENDTIME > @StartTime ");
sql.AppendLine(" LEFT JOIN T_QM_USER USR ");
sql.AppendLine(" AND T.ENDTIME <= @EndTime");
sql.AppendLine(" ON USR.USERNAME = 'SYSTEM' ");
sql.AppendLine(" GROUP BY T.MATERIALNO ");
sql.AppendLine(" WHERE S.MATERIAL_ATTRIBUTE='2' ");
sql.AppendLine(" AND C.MFG_MATERIAL_CODE IS NOT NULL ");
sql.AppendLine(" AND T.CREATEDATE > @StartTime ");
sql.AppendLine(" AND T.CREATEDATE <= @EndTime ");
sql.AppendLine(" AND T.MACHINECODDE IS NOT NULL ");
sql.AppendLine(" GROUP BY C.MFG_MATERIAL_CODE, USR.USERID, C.ORDERIDENTITY ");
returnsql.ToString();
returnsql.ToString();
}
}
protectedstringGetGenericStatisticsSqlForINJECT()
protectedstringGetGenericStatisticsSqlForINJECT()
{
{
StringBuildersql=newStringBuilder();
StringBuildersql=newStringBuilder();
sql.AppendLine(" INSERT INTO T_AW_COMPLETE_STATISTICS ");
sql.AppendLine(" SELECT NEWID(), ");
sql.AppendLine(" update T_AW_COMPLETE_TJSTATISTICS set DELFLAG ='1' ");
sql.AppendLine(" C.MFG_MATERIAL_CODE AS MATERIALNO, ");
sql.AppendLine(" WHERE DELFLAG ='0'");
sql.AppendLine(" COUNT(*) AS SYSCOMPLETECOUNT, ");