Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-center-auto
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
data-center-auto
Commits
68bd9651
Commit
68bd9651
authored
Feb 14, 2023
by
lizefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 新现金流,项目视图
parent
225ca63a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
193 additions
and
18 deletions
+193
-18
dc_ana_deviation_dao.cs
AutoTurnOver.DB/dc_ana_deviation_dao.cs
+107
-16
DeviationServices.cs
AutoTurnOver.Services/DeviationServices.cs
+57
-2
DeviationController.cs
AutoTurnOver/Controllers/DeviationController.cs
+29
-0
No files found.
AutoTurnOver.DB/dc_ana_deviation_dao.cs
View file @
68bd9651
...
...
@@ -197,7 +197,7 @@ namespace AutoTurnOver.DB
});
// 偏差分析 【产品成本预计偏差值】、【产品成本预计偏差比例】、【销售数量预计偏差值】、【销售数量预计偏差比例】、【产品成本实际偏差值】、【产品成本实际偏差比例】、【销售数量实际偏差值】、【销售数量实际偏差比例】
SaveDeviation
(
datas
,
new
dc_ana_deviation
{
bdate
=
now
,
...
...
@@ -365,7 +365,7 @@ namespace AutoTurnOver.DB
var
viewDatas
=
new
List
<
deviation_view_dto
>()
{
};
var
year
=
DateTime
.
Now
.
Year
;
var
allDatas
=
datas
.
GroupBy
(
s
=>
new
{
s
.
sku
,
s
.
project
,
s
.
field_type
,
s
.
field
}).
OrderByDescending
(
s
=>
s
.
Key
.
field
).
OrderByDescending
(
s
=>
s
.
Key
.
field_type
).
OrderBy
(
s
=>
s
.
Key
.
project
).
OrderBy
(
s
=>
s
.
Key
.
sku
).
ToList
();
var
allDatas
=
datas
.
GroupBy
(
s
=>
new
{
s
.
sku
,
s
.
project
,
s
.
field_type
,
s
.
field
}).
OrderByDescending
(
s
=>
s
.
Key
.
field
).
OrderByDescending
(
s
=>
s
.
Key
.
field_type
).
OrderBy
(
s
=>
s
.
Key
.
project
).
OrderBy
(
s
=>
s
.
Key
.
sku
).
ToList
();
var
pageDatas
=
allDatas
.
Skip
(
offset
).
Take
(
limit
).
ToList
();
foreach
(
var
item
in
pageDatas
)
{
...
...
@@ -375,18 +375,18 @@ namespace AutoTurnOver.DB
field_type
=
item
.
Key
.
field_type
,
group_key
=
item
.
Key
.
sku
,
project
=
item
.
Key
.
project
,
month1
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-01"
,
item
.
Key
.
field
),
month2
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-02"
,
item
.
Key
.
field
),
month3
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-03"
,
item
.
Key
.
field
),
month4
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-04"
,
item
.
Key
.
field
),
month5
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-05"
,
item
.
Key
.
field
),
month6
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-06"
,
item
.
Key
.
field
),
month7
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-07"
,
item
.
Key
.
field
),
month8
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-08"
,
item
.
Key
.
field
),
month9
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-09"
,
item
.
Key
.
field
),
month10
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-10"
,
item
.
Key
.
field
),
month11
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-11"
,
item
.
Key
.
field
),
month12
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-12"
,
item
.
Key
.
field
)
month1
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-01"
),
month2
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-02"
),
month3
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-03"
),
month4
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-04"
),
month5
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-05"
),
month6
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-06"
),
month7
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-07"
),
month8
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-08"
),
month9
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-09"
),
month10
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-10"
),
month11
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-11"
),
month12
=
GetVal
(
item
.
AsQueryable
(),
$"
{
year
}
-12"
)
};
viewDatas
.
Add
(
itemData
);
...
...
@@ -399,13 +399,103 @@ namespace AutoTurnOver.DB
return
viewDatas
;
}
public
static
string
GetVal
(
IQueryable
<
dc_ana_deviation
>
list
,
string
date_str
,
string
field
)
public
static
IEnumerable
<
deviation_view_dto
>
GetProjectViews
(
deviation_search_dto
search_data
,
int
offset
,
int
limit
,
ref
int
total
)
{
var
datas
=
GetDatas
(
search_data
);
var
viewDatas
=
new
List
<
deviation_view_dto
>()
{
};
var
year
=
DateTime
.
Now
.
Year
;
var
allDatas
=
datas
.
GroupBy
(
s
=>
new
{
s
.
project
,
s
.
field_type
,
s
.
field
}).
OrderByDescending
(
s
=>
s
.
Key
.
field
).
OrderByDescending
(
s
=>
s
.
Key
.
field_type
).
OrderBy
(
s
=>
s
.
Key
.
project
).
ToList
();
var
pageDatas
=
allDatas
.
Skip
(
offset
).
Take
(
limit
).
ToList
();
foreach
(
var
item
in
pageDatas
)
{
deviation_view_dto
itemData
=
new
deviation_view_dto
()
{
field
=
item
.
Key
.
field
,
field_type
=
item
.
Key
.
field_type
,
group_key
=
item
.
Key
.
project
,
project
=
item
.
Key
.
project
,
month1
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-01"
),
month2
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-02"
),
month3
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-03"
),
month4
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-04"
),
month5
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-05"
),
month6
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-06"
),
month7
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-07"
),
month8
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-08"
),
month9
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-09"
),
month10
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-10"
),
month11
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-11"
),
month12
=
GetSumVal
(
datas
,
item
.
AsQueryable
(),
$"
{
year
}
-12"
)
};
viewDatas
.
Add
(
itemData
);
}
total
=
allDatas
.
Count
();
return
viewDatas
;
}
public
static
string
GetSumVal
(
List
<
dc_ana_deviation
>
all
,
IQueryable
<
dc_ana_deviation
>
list
,
string
date_str
)
{
string
field
=
list
.
FirstOrDefault
().
field
;
string
project
=
list
.
FirstOrDefault
().
project
;
string
val
=
""
;
var
data
=
list
.
Where
(
s
=>
date_str
==
s
.
date_str
).
ToList
();
if
(
data
!=
null
&&
data
.
Count
>=
1
)
{
if
(
field
.
Contains
(
"比例"
))
{
switch
(
field
)
{
case
"销售数量预计偏差比例"
:
val
=
all
.
Where
(
s
=>
s
.
field
==
"销售数量预计偏差值"
&&
s
.
field_type
==
"偏差分析"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
).
Division
(
all
.
Where
(
s
=>
s
.
field
==
"销售产品数量"
&&
s
.
field_type
==
"预测值"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
)
).
ToString
(
"p"
);
break
;
case
"销售数量实际偏差比例"
:
val
=
all
.
Where
(
s
=>
s
.
field
==
"销售数量实际偏差值"
&&
s
.
field_type
==
"偏差分析"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
).
Division
(
all
.
Where
(
s
=>
s
.
field
==
"销售产品数量"
&&
s
.
field_type
==
"预测值"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
)
).
ToString
(
"p"
);
break
;
case
"产品成本预计偏差比例"
:
val
=
all
.
Where
(
s
=>
s
.
field
==
"销售数量实际偏差值"
&&
s
.
field_type
==
"偏差分析"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
).
Division
(
all
.
Where
(
s
=>
s
.
field
==
"销售产品数量"
&&
s
.
field_type
==
"预测值"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
)
).
ToString
(
"p"
);
break
;
case
"产品成本实际偏差比例"
:
val
=
all
.
Where
(
s
=>
s
.
field
==
"销售数量实际偏差值"
&&
s
.
field_type
==
"偏差分析"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
).
Division
(
all
.
Where
(
s
=>
s
.
field
==
"销售产品数量"
&&
s
.
field_type
==
"预测值"
&&
s
.
project
==
project
).
Sum
(
s
=>
s
.
val
)
).
ToString
(
"p"
);
break
;
default
:
val
=
""
;
break
;
}
}
else
{
val
=
Math
.
Round
(
data
.
Sum
(
s
=>
s
.
val
),
1
).
ToString
();
}
}
return
val
;
}
public
static
string
GetVal
(
IQueryable
<
dc_ana_deviation
>
list
,
string
date_str
)
{
string
field
=
list
.
FirstOrDefault
().
field
;
string
val
=
""
;
var
data
=
list
.
FirstOrDefault
(
s
=>
date_str
==
s
.
date_str
);
if
(
data
!=
null
)
{
val
=
Math
.
Round
(
data
.
val
,
1
).
ToString
();
val
=
Math
.
Round
(
data
.
val
,
1
).
ToString
();
if
(
field
.
Contains
(
"比例"
))
{
return
data
.
val
.
ToString
(
"p"
);
...
...
@@ -416,6 +506,7 @@ namespace AutoTurnOver.DB
}
public
static
List
<
dc_ana_deviation
>
GetDatas
(
deviation_search_dto
search_data
)
{
var
yearBdate
=
DateTime
.
Parse
(
DateTime
.
Now
.
ToString
(
"yyyy-01-01 00:00:00"
));
...
...
AutoTurnOver.Services/DeviationServices.cs
View file @
68bd9651
...
...
@@ -28,12 +28,18 @@ namespace AutoTurnOver.Services
return
datas
;
}
public
IEnumerable
<
deviation_view_dto
>
GetProjectViews
(
deviation_search_dto
search_data
,
int
offset
,
int
limit
,
ref
int
total
)
{
var
datas
=
dc_ana_deviation_dao
.
GetProjectViews
(
search_data
,
offset
,
limit
,
ref
total
);
return
datas
;
}
public
List
<
string
>
GetProjects
()
{
return
dc_ana_deviation_dao
.
GetProjects
();
}
internal
string
SkuExport
(
deviation_search_dto
search_data
,
out
int
rows
)
public
string
SkuExport
(
deviation_search_dto
search_data
,
out
int
rows
)
{
try
{
...
...
@@ -42,7 +48,7 @@ namespace AutoTurnOver.Services
var
fileName
=
AppContext
.
BaseDirectory
+
$@"新现金流报表(sku)-
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}{
Guid
.
NewGuid
()}
.csv"
;
DataTable
table
=
new
DataTable
();
var
dateYear
=
DateTime
.
Now
.
Year
;
List
<
string
>
cols
=
new
List
<
string
>
{
"数据类型"
,
"字段"
,
"sku"
,
$"
{
dateYear
}
-01"
,
$"
{
dateYear
}
-02"
,
$"
{
dateYear
}
-03"
,
$"
{
dateYear
}
-04"
,
$"
{
dateYear
}
-05"
,
$"
{
dateYear
}
-06"
,
$"
{
dateYear
}
-07"
,
$"
{
dateYear
}
-08"
List
<
string
>
cols
=
new
List
<
string
>
{
"数据类型"
,
"字段"
,
"sku"
,
"项目"
,
$"
{
dateYear
}
-01"
,
$"
{
dateYear
}
-02"
,
$"
{
dateYear
}
-03"
,
$"
{
dateYear
}
-04"
,
$"
{
dateYear
}
-05"
,
$"
{
dateYear
}
-06"
,
$"
{
dateYear
}
-07"
,
$"
{
dateYear
}
-08"
,
$"
{
dateYear
}
-09"
,
$"
{
dateYear
}
-10"
,
$"
{
dateYear
}
-11"
,
$"
{
dateYear
}
-12"
};
foreach
(
var
item
in
cols
)
...
...
@@ -57,6 +63,7 @@ namespace AutoTurnOver.Services
DataRow
row
=
table
.
NewRow
();
row
[
"数据类型"
]
=
itemData
.
field_type
;
row
[
"字段"
]
=
itemData
.
field
;
row
[
"项目"
]
=
itemData
.
project
;
row
[
"sku"
]
=
itemData
.
group_key
;
row
[
$"
{
dateYear
}
-01"
]
=
itemData
.
month1
;
row
[
$"
{
dateYear
}
-02"
]
=
itemData
.
month2
;
...
...
@@ -81,5 +88,53 @@ namespace AutoTurnOver.Services
throw
;
}
}
public
string
ProjectExport
(
deviation_search_dto
search_data
,
out
int
rows
)
{
try
{
var
services
=
new
DailyServices
();
var
fileName
=
AppContext
.
BaseDirectory
+
$@"新现金流报表(sku)-
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}{
Guid
.
NewGuid
()}
.csv"
;
DataTable
table
=
new
DataTable
();
var
dateYear
=
DateTime
.
Now
.
Year
;
List
<
string
>
cols
=
new
List
<
string
>
{
"数据类型"
,
"字段"
,
"项目"
,
$"
{
dateYear
}
-01"
,
$"
{
dateYear
}
-02"
,
$"
{
dateYear
}
-03"
,
$"
{
dateYear
}
-04"
,
$"
{
dateYear
}
-05"
,
$"
{
dateYear
}
-06"
,
$"
{
dateYear
}
-07"
,
$"
{
dateYear
}
-08"
,
$"
{
dateYear
}
-09"
,
$"
{
dateYear
}
-10"
,
$"
{
dateYear
}
-11"
,
$"
{
dateYear
}
-12"
};
foreach
(
var
item
in
cols
)
{
table
.
Columns
.
Add
(
item
);
}
int
total
=
0
;
var
findDataList
=
DB
.
dc_ana_deviation_dao
.
GetProjectViews
(
search_data
,
0
,
int
.
MaxValue
,
ref
total
);
rows
=
findDataList
.
Count
();
foreach
(
var
itemData
in
findDataList
)
{
DataRow
row
=
table
.
NewRow
();
row
[
"数据类型"
]
=
itemData
.
field_type
;
row
[
"字段"
]
=
itemData
.
field
;
row
[
"项目"
]
=
itemData
.
group_key
;
row
[
$"
{
dateYear
}
-01"
]
=
itemData
.
month1
;
row
[
$"
{
dateYear
}
-02"
]
=
itemData
.
month2
;
row
[
$"
{
dateYear
}
-03"
]
=
itemData
.
month3
;
row
[
$"
{
dateYear
}
-04"
]
=
itemData
.
month4
;
row
[
$"
{
dateYear
}
-05"
]
=
itemData
.
month5
;
row
[
$"
{
dateYear
}
-06"
]
=
itemData
.
month6
;
row
[
$"
{
dateYear
}
-07"
]
=
itemData
.
month7
;
row
[
$"
{
dateYear
}
-08"
]
=
itemData
.
month8
;
row
[
$"
{
dateYear
}
-09"
]
=
itemData
.
month9
;
row
[
$"
{
dateYear
}
-10"
]
=
itemData
.
month10
;
row
[
$"
{
dateYear
}
-11"
]
=
itemData
.
month11
;
row
[
$"
{
dateYear
}
-12"
]
=
itemData
.
month12
;
table
.
Rows
.
Add
(
row
);
}
CsvFileHelper
.
SaveCSV
(
table
,
fileName
);
return
fileName
;
}
catch
(
Exception
)
{
throw
;
}
}
}
}
AutoTurnOver/Controllers/DeviationController.cs
View file @
68bd9651
...
...
@@ -49,6 +49,23 @@ namespace AutoTurnOver.Controllers
total
=
total
,
});
}
public
JsonResult
GetProjectViews
(
string
project
,
string
sku
,
int
offset
,
int
limit
,
string
order
,
string
sort
)
{
var
m
=
new
deviation_search_dto
{
project
=
project
,
sku
=
sku
};
var
services
=
new
DeviationServices
();
var
total
=
0
;
var
list
=
services
.
GetProjectViews
(
m
,
offset
,
limit
,
ref
total
);
return
new
JsonResult
(
new
{
rows
=
list
,
total
=
total
,
});
}
public
JsonResult
Projects
()
{
...
...
@@ -67,6 +84,18 @@ namespace AutoTurnOver.Controllers
return
new
JsonResult
(
new
{
success
=
true
});
}
public
ActionResult
GetProjectViewsExport
([
FromForm
]
deviation_search_dto
m
)
{
var
user
=
AutoUtility
.
GetUser
();
dc_task_download_dao
.
PushData
<
deviation_search_dto
>(
new
dc_task_download
{
parameter
=
m
.
ToJson
(),
task_name
=
"新现金流报表(项目)"
},
user
);
return
new
JsonResult
(
new
{
success
=
true
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment