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