diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs index d7e2a046..6890218a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs @@ -48,6 +48,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { str += string.Format(" and beginTime<='{0}' ", end); } + else + { + var datestr = version.Substring(0, 4) + "-" + version.Substring(4, 2) + "-01"; + var date = DateTime.Parse(datestr).AddMonths(1).AddDays(-1); + var datetime = date.ToShortDateString() + " 23:59:59 "; + str += string.Format(" and beginTime<='{0}' ", datetime); + } var sqlString = " SELECT\n" + @@ -143,7 +150,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report string _sql = string.Format(sqlString, str, version); ; - var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + var _query = DbConnection.Query(_sql, null, null,true, 1200, null); var _list = _query.ToList(); @@ -161,204 +168,208 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetDiffReport1(string year, string begin, string end, string customcode, string version, string materialCode, string materialGroup, string sapCode) { -// string str = " "; -// if (!string.IsNullOrEmpty(begin)) -// { -// str += string.Format(" and beginTime>='{0}' ", begin); -// } -// if (!string.IsNullOrEmpty(end)) -// { -// str += string.Format(" and beginTime<='{0}' ", end); -// } - -// var sqlString = -//"SELECT\n" + -//"2 WMSState,\n" + -//"temp1.WMSBillNum,\n" + -//"temp1.UnSettleVersion\t\t ,\n" + -//"temp1.CP5Time\t\t\t\t ,\n" + -//"temp1.MaterialCode\t\t\t ,\n" + -//"temp1.ChassisNumber\t\t\t ,\n" + -//"temp1.KENNCode\t\t\t\t ,\n" + -//"temp1.chassisNumber2\t\t ,\n" + -//"temp1.KENNCode2\t\t\t\t ,\n" + -//"temp1.QTY\t\t\t\t\t ,\n" + -//"temp1.ParentSapMaterialCode\t ,\n" + -//"temp1.FLAG\t\t\t\t\t ,\n" + -//"temp1.UnSettleQty\t\t\t ,\n" + -//"temp1.MaterialGroup\t\t\t ,\n" + -//"temp1.MaterialDesc\t\t\t ,\n" + -//"temp1.ParentMaterialDesc\t ,\n" + -//"temp1.SapMaterialCode\t\t ,\n" + -//"temp2.Price,\n" + -//"ISNULL( temp1.QTY, 0 )* ISNULL( temp2.Price, 0 ) AMT,\n" + -//"Round(ISNULL( temp1.DiffQty, 0 )* ISNULL( temp2.Price, 0 ),2) DiffAMT,\n" + -//"temp1.DiffQty\n"+ - - -//"FROM\n" + -//"(\n" + -//"SELECT\n" + -//"A.*,\n" + -//"Isnull(F.Qty, 0) UnSettleQty,\n" + -//"B.EstimateTypeDesc MaterialGroup,\n" + -//"B.MaterialDesc MaterialDesc,\n" + -//"d.MaterialDesc ParentMaterialDesc,\n" + -//"B.MaterialCode SapMaterialCode,\n" + -//"A.Qty-Isnull(F.Qty,\n" + -//"0) DiffQty\n" + -//"FROM\n" + -//"(\n" + -//"select\n" + -//"\n" + -//"MaterialCode,\n" + -//"ChassisNumber,\n" + -//"KENNCode,\n" + -//"ChassisNumber2,\n" + -//"KENNCode2,\n" + -//"flag,\n" + -//"\n" + -//"STUFF((\n" + -//"SELECT\n" + -//"',' + ErpMaterialCode\n" + -//"FROM\n" + -//"Set_fis subTitle\n" + -//"WHERE\n" + -//"KENNCode = tm1.KENNCode2\n" + -//"and ChassisNumber2 = tm1.ChassisNumber2\n" + -//"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + -//"1,\n" + -//"1,\n" + -//"'') AS ParentSapMaterialCode,\n" + -//"STUFF((\n" + -//"SELECT\n" + -//"',' + WMSBillNum\n" + -//"FROM\n" + -//"Set_fis subTitle\n" + -//"WHERE\n" + -//"KENNCode = tm1.KENNCode2\n" + -//"and ChassisNumber2 = tm1.ChassisNumber2\n" + -//"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + -//"1,\n" + -//"1,\n" + -//"'') AS WMSBillNum,\n" + -//"STUFF((\n" + -//"SELECT\n" + -//"',' + CONVERT(VARCHAR(10),CP5Time,120)\n" + -//"FROM\n" + -//"Set_fis subTitle\n" + -//"WHERE\n" + -//"KENNCode = tm1.KENNCode2\n" + -//"and ChassisNumber2 = tm1.ChassisNumber2\n" + -//"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + -//"1,\n" + -//"1,\n" + -//"'') AS CP5Time,\n" + -//"STUFF((\n" + -//"SELECT\n" + -//"',' + UnSettleVersion\n" + -//"FROM\n" + -//"Set_fis subTitle\n" + -//"WHERE\n" + -//"KENNCode = tm1.KENNCode2\n" + -//"and ChassisNumber2 = tm1.ChassisNumber2\n" + -//"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + -//"1,\n" + -//"1,\n" + -//"'') AS UnSettleVersion,\n" + -//"sum(qty) qty\n" + -//"from\n" + -//"\n" + -//"(\n" + -//"SELECT\n" + -//"WMSState,\n" + -//"WMSBillNum,\n" + -//"UnSettleVersion,\n" + -//"BeginTime CP5Time,\n" + -//"ItemCode MaterialCode,\n" + -//"ChassisNumber,\n" + -//"OrderBillNum KENNCode,\n" + -//"ChassisNumber2,\n" + -//"KENNCode KENNCode2,\n" + -//"QTY,\n" + -//"ErpMaterialCode ,\n" + -//"'' FLAG\n" + -//"FROM\n" + -//"Set_fis\n" + -//"where\n" + -//"1 = 1\n" + -//"AND STATE = 0 {0}\n" + -//"UNION ALL\n" + -//"SELECT\n" + -//"\n" + -//"WMSState,\n" + -//"WMSBillNum,\n" + -//"UnSettleVersion,\n" + -//"BeginTime CP5Time,\n" + -//"ItemCode MaterialCode,\n" + -//"ChassisNumber,\n" + -//"OrderBillNum KENNCode,\n" + -//"ChassisNumber2,\n" + -//"KENNCode KENNCode2,\n" + -//"QTY,\n" + -//"ErpMaterialCode ,\n" + -//"'L' FLAG\n" + -//"FROM\n" + -//"Set_fis\n" + -//"WHERE\n" + -//"1 = 1\n" + -//"AND STATE = 4 {0}\n" + -//")\n" + -//"tm1\n" + -//"GROUP BY\n" + -//"MaterialCode,\n" + -//"KENNCode2,\n" + -//"ChassisNumber2,\n" + -//"KENNCode,\n" + -//"ChassisNumber,\n" + -//"FLAG\n" + -//") A\n" + -//"left join (\n" + -//"select\n" + -//"*\n" + -//"from\n" + -//"Set_Unsettle\n" + -//"where\n" + -//"version = '{1}') f\n" + -//"on\n" + -//"a.MaterialCode = f.MaterialCode\n" + -//"and a.KENNCode2 = f.KENNCode\n" + -//"and a.ChassisNumber2 = f.ChassisNumber\n" + -//"LEFT JOIN Set_material B ON\n" + -//"a.MaterialCode = b.CustomerPartCode\n" + -//"LEFT JOIN (\n" + -//"select\n" + -//"max(Id) Id,\n" + -//"MaterialCode,\n" + -//"MaterialDesc\n" + -//"from\n" + -//"Set_material\n" + -//"group by\n" + -//"MaterialCode,\n" + -//"MaterialDesc) d ON\n" + -//"Substring(a.ParentSapMaterialCode,1,8) = d.MaterialCode\n" + -//") temp1\n" + -//"LEFT JOIN (\n" + -//"SELECT\n" + -//"Price,\n" + -//"MaterialCode\n" + -//"FROM\n" + -//"Set_PriceList\n" + -//"WHERE\n" + -//"version = (\n" + -//"SELECT\n" + -//"Max(Version)\n" + -//"FROM\n" + -//"Set_PriceList ) ) temp2 ON\n" + -//"temp1.SapMaterialCode = temp2.MaterialCode\n"; - - - string _sql= string.Format("exec [dbo].[p_SystemR3Diff] '{0}','{1}'",string.IsNullOrEmpty(end)?DateTime.Now.ToShortDateString():end + // string str = " "; + // if (!string.IsNullOrEmpty(begin)) + // { + // str += string.Format(" and beginTime>='{0}' ", begin); + // } + // if (!string.IsNullOrEmpty(end)) + // { + // str += string.Format(" and beginTime<='{0}' ", end); + // } + + // var sqlString = + //"SELECT\n" + + //"2 WMSState,\n" + + //"temp1.WMSBillNum,\n" + + //"temp1.UnSettleVersion\t\t ,\n" + + //"temp1.CP5Time\t\t\t\t ,\n" + + //"temp1.MaterialCode\t\t\t ,\n" + + //"temp1.ChassisNumber\t\t\t ,\n" + + //"temp1.KENNCode\t\t\t\t ,\n" + + //"temp1.chassisNumber2\t\t ,\n" + + //"temp1.KENNCode2\t\t\t\t ,\n" + + //"temp1.QTY\t\t\t\t\t ,\n" + + //"temp1.ParentSapMaterialCode\t ,\n" + + //"temp1.FLAG\t\t\t\t\t ,\n" + + //"temp1.UnSettleQty\t\t\t ,\n" + + //"temp1.MaterialGroup\t\t\t ,\n" + + //"temp1.MaterialDesc\t\t\t ,\n" + + //"temp1.ParentMaterialDesc\t ,\n" + + //"temp1.SapMaterialCode\t\t ,\n" + + //"temp2.Price,\n" + + //"ISNULL( temp1.QTY, 0 )* ISNULL( temp2.Price, 0 ) AMT,\n" + + //"Round(ISNULL( temp1.DiffQty, 0 )* ISNULL( temp2.Price, 0 ),2) DiffAMT,\n" + + //"temp1.DiffQty\n"+ + + + //"FROM\n" + + //"(\n" + + //"SELECT\n" + + //"A.*,\n" + + //"Isnull(F.Qty, 0) UnSettleQty,\n" + + //"B.EstimateTypeDesc MaterialGroup,\n" + + //"B.MaterialDesc MaterialDesc,\n" + + //"d.MaterialDesc ParentMaterialDesc,\n" + + //"B.MaterialCode SapMaterialCode,\n" + + //"A.Qty-Isnull(F.Qty,\n" + + //"0) DiffQty\n" + + //"FROM\n" + + //"(\n" + + //"select\n" + + //"\n" + + //"MaterialCode,\n" + + //"ChassisNumber,\n" + + //"KENNCode,\n" + + //"ChassisNumber2,\n" + + //"KENNCode2,\n" + + //"flag,\n" + + //"\n" + + //"STUFF((\n" + + //"SELECT\n" + + //"',' + ErpMaterialCode\n" + + //"FROM\n" + + //"Set_fis subTitle\n" + + //"WHERE\n" + + //"KENNCode = tm1.KENNCode2\n" + + //"and ChassisNumber2 = tm1.ChassisNumber2\n" + + //"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + + //"1,\n" + + //"1,\n" + + //"'') AS ParentSapMaterialCode,\n" + + //"STUFF((\n" + + //"SELECT\n" + + //"',' + WMSBillNum\n" + + //"FROM\n" + + //"Set_fis subTitle\n" + + //"WHERE\n" + + //"KENNCode = tm1.KENNCode2\n" + + //"and ChassisNumber2 = tm1.ChassisNumber2\n" + + //"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + + //"1,\n" + + //"1,\n" + + //"'') AS WMSBillNum,\n" + + //"STUFF((\n" + + //"SELECT\n" + + //"',' + CONVERT(VARCHAR(10),CP5Time,120)\n" + + //"FROM\n" + + //"Set_fis subTitle\n" + + //"WHERE\n" + + //"KENNCode = tm1.KENNCode2\n" + + //"and ChassisNumber2 = tm1.ChassisNumber2\n" + + //"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + + //"1,\n" + + //"1,\n" + + //"'') AS CP5Time,\n" + + //"STUFF((\n" + + //"SELECT\n" + + //"',' + UnSettleVersion\n" + + //"FROM\n" + + //"Set_fis subTitle\n" + + //"WHERE\n" + + //"KENNCode = tm1.KENNCode2\n" + + //"and ChassisNumber2 = tm1.ChassisNumber2\n" + + //"and ItemCode = tm1.MaterialCode FOR XML PATH('')),\n" + + //"1,\n" + + //"1,\n" + + //"'') AS UnSettleVersion,\n" + + //"sum(qty) qty\n" + + //"from\n" + + //"\n" + + //"(\n" + + //"SELECT\n" + + //"WMSState,\n" + + //"WMSBillNum,\n" + + //"UnSettleVersion,\n" + + //"BeginTime CP5Time,\n" + + //"ItemCode MaterialCode,\n" + + //"ChassisNumber,\n" + + //"OrderBillNum KENNCode,\n" + + //"ChassisNumber2,\n" + + //"KENNCode KENNCode2,\n" + + //"QTY,\n" + + //"ErpMaterialCode ,\n" + + //"'' FLAG\n" + + //"FROM\n" + + //"Set_fis\n" + + //"where\n" + + //"1 = 1\n" + + //"AND STATE = 0 {0}\n" + + //"UNION ALL\n" + + //"SELECT\n" + + //"\n" + + //"WMSState,\n" + + //"WMSBillNum,\n" + + //"UnSettleVersion,\n" + + //"BeginTime CP5Time,\n" + + //"ItemCode MaterialCode,\n" + + //"ChassisNumber,\n" + + //"OrderBillNum KENNCode,\n" + + //"ChassisNumber2,\n" + + //"KENNCode KENNCode2,\n" + + //"QTY,\n" + + //"ErpMaterialCode ,\n" + + //"'L' FLAG\n" + + //"FROM\n" + + //"Set_fis\n" + + //"WHERE\n" + + //"1 = 1\n" + + //"AND STATE = 4 {0}\n" + + //")\n" + + //"tm1\n" + + //"GROUP BY\n" + + //"MaterialCode,\n" + + //"KENNCode2,\n" + + //"ChassisNumber2,\n" + + //"KENNCode,\n" + + //"ChassisNumber,\n" + + //"FLAG\n" + + //") A\n" + + //"left join (\n" + + //"select\n" + + //"*\n" + + //"from\n" + + //"Set_Unsettle\n" + + //"where\n" + + //"version = '{1}') f\n" + + //"on\n" + + //"a.MaterialCode = f.MaterialCode\n" + + //"and a.KENNCode2 = f.KENNCode\n" + + //"and a.ChassisNumber2 = f.ChassisNumber\n" + + //"LEFT JOIN Set_material B ON\n" + + //"a.MaterialCode = b.CustomerPartCode\n" + + //"LEFT JOIN (\n" + + //"select\n" + + //"max(Id) Id,\n" + + //"MaterialCode,\n" + + //"MaterialDesc\n" + + //"from\n" + + //"Set_material\n" + + //"group by\n" + + //"MaterialCode,\n" + + //"MaterialDesc) d ON\n" + + //"Substring(a.ParentSapMaterialCode,1,8) = d.MaterialCode\n" + + //") temp1\n" + + //"LEFT JOIN (\n" + + //"SELECT\n" + + //"Price,\n" + + //"MaterialCode\n" + + //"FROM\n" + + //"Set_PriceList\n" + + //"WHERE\n" + + //"version = (\n" + + //"SELECT\n" + + //"Max(Version)\n" + + //"FROM\n" + + //"Set_PriceList ) ) temp2 ON\n" + + //"temp1.SapMaterialCode = temp2.MaterialCode\n"; + + + var datestr = version.Substring(0, 4) + "-" + version.Substring(4, 2) + "-01"; + var date = DateTime.Parse(datestr).AddMonths(1).AddDays(-1); + var datetime = date.ToShortDateString() + " 23:59:59 "; + + string _sql= string.Format("exec [dbo].[p_SystemR3Diff] '{0}','{1}'",string.IsNullOrEmpty(end)? datetime : end , version); var _query = DbConnection.Query(_sql, null, null, true, 1200,System.Data.CommandType.Text); var _list = _query.ToList();