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
7791e139
Commit
7791e139
authored
Jan 05, 2019
by
lizefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整自动下单周转公式
parent
7ef26cc3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
376 additions
and
2 deletions
+376
-2
db_config.cs
AutoTurnOver.DB/db_config.cs
+125
-0
dc_auto_turnover.cs
AutoTurnOver.DB/dc_auto_turnover.cs
+8
-0
dc_auto_config_delivery.cs
AutoTurnOver.Models/dc_auto_config_delivery.cs
+64
-0
dc_auto_turnover.cs
AutoTurnOver.Models/dc_auto_turnover.cs
+15
-0
ConfigServices.cs
AutoTurnOver.Services/ConfigServices.cs
+98
-1
ConfigController.cs
AutoTurnOver/Controllers/ConfigController.cs
+64
-0
ReportsController.cs
AutoTurnOver/Controllers/ReportsController.cs
+2
-1
No files found.
AutoTurnOver.DB/db_config.cs
View file @
7791e139
...
...
@@ -275,5 +275,130 @@ left join dc_base_warehouse as dbw on dacp.warehouse_code = dbw.warehouse_code w
#
endregion
#
region
供应链长度规则设置
/// <summary>
/// 获取供应链长度规则设置分页列表
/// </summary>
/// <param name="m"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public
static
List
<
dc_auto_config_delivery_dto
>
ConfigDeliveryList
(
Condition_ConfigPromotion
m
,
int
offset
,
int
limit
,
ref
int
total
)
{
var
list
=
new
List
<
dc_auto_config_delivery_dto
>();
try
{
var
sql
=
@"select dacp.* from dc_auto_config_delivery as dacp
left join dc_base_warehouse as dbw on dacp.variable_code = dbw.warehouse_code and type = 3
where 1 = 1 "
;
if
(!
string
.
IsNullOrWhiteSpace
(
m
.
warehousetype
))
{
sql
+=
" and dbw.hq_type="
+
$"'
{
m
.
warehousetype
}
'"
;
}
if
(
m
.
warehousearea
>
0
)
{
sql
+=
" and dbw.area_id="
+
m
.
warehousearea
;
}
if
(
m
.
IsEffective
==
true
)
{
sql
+=
$" and dacp.status=1 "
;
}
if
(!
string
.
IsNullOrWhiteSpace
(
m
.
sku
))
{
sql
+=
" and ( type = 1 and dacp.variable_code like '%"
+
m
.
sku
+
"%' )"
;
}
if
(!
string
.
IsNullOrWhiteSpace
(
m
.
warehousecode
))
{
sql
+=
" and dbw.warehouse_code='"
+
m
.
warehousecode
+
"'"
;
}
total
=
_connection
.
ExecuteScalar
<
int
>(
"select count(0) from ("
+
sql
+
") tb1"
);
var
obj
=
_connection
.
Query
<
dc_auto_config_delivery_dto
>(
sql
+
" limit "
+
offset
+
","
+
limit
);
return
obj
.
AsList
();
}
catch
(
Exception
)
{
return
list
;
}
}
/// <summary>
/// 保存供应链长度规则
/// </summary>
/// <param name="m">销售设置model</param>
/// <param name="username">当前操作人名称</param>
/// <returns></returns>
public
static
string
SaveConfigDelivery
(
Models
.
dc_auto_config_delivery
m
,
string
username
)
{
var
obj
=
_connection
.
QueryFirstOrDefault
<
Models
.
dc_auto_config_delivery
>(
"select * from dc_auto_config_delivery where id="
+
m
.
id
);
if
(
obj
==
null
)
{
obj
=
new
dc_auto_config_delivery
{
gmt_create
=
DateTime
.
Now
,
};
}
obj
.
id
=
m
.
id
;
obj
.
variable_code
=
m
.
variable_code
;
obj
.
variable_name
=
m
.
variable_name
;
obj
.
bl_operator
=
username
??
""
;
obj
.
gmt_modified
=
DateTime
.
Now
;
obj
.
remark
=
m
.
remark
;
obj
.
status
=
m
.
status
;
obj
.
type
=
m
.
type
;
obj
.
tranfer_bale
=
m
.
tranfer_bale
;
obj
.
tranfer_head
=
m
.
tranfer_head
;
obj
.
abroad_inbound
=
m
.
abroad_inbound
;
try
{
if
(
obj
.
id
>
0
)
{
var
result
=
_connection
.
Update
<
Models
.
dc_auto_config_delivery
>(
obj
);
return
result
>
0
?
""
:
"保存异常,请重试!"
;
}
else
{
var
result
=
_connection
.
Insert
<
Models
.
dc_auto_config_delivery
>(
obj
);
return
result
.
HasValue
&&
result
.
Value
>
0
?
""
:
"提交异常,请重试!"
;
}
}
catch
(
Exception
ex
)
{
return
ex
.
Message
;
}
}
/// <summary>
/// 获取安全库存规则设置详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
static
dc_auto_config_delivery
GetConfigDeliveryById
(
int
id
)
{
return
_connection
.
QueryFirstOrDefault
<
dc_auto_config_delivery
>(
"select * from dc_auto_config_delivery where id="
+
id
);
}
#
endregion
}
}
AutoTurnOver.DB/dc_auto_turnover.cs
View file @
7791e139
...
...
@@ -34,6 +34,14 @@ left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_
left join dc_base_warehouse as t3 on dat.warehouse_code = t3.warehouse_code
where 1=1 "
;
if
(
m
.
hasDefectConfig
==
true
)
{
sql
+=
" and ( dat.abroad_inbound_delivery <=0 or dat.transfer_bale_delivery <=0 or dat.transfer_delivery <=0 ) "
;
}
if
(
m
.
hasDefectConfig
==
false
)
{
sql
+=
" and ( dat.abroad_inbound_delivery >0 and dat.transfer_bale_delivery >0 and dat.transfer_delivery >0 ) "
;
}
if
(!
string
.
IsNullOrWhiteSpace
(
m
.
warehousetype
))
{
sql
+=
" and t3.hq_type="
+
$"'
{
m
.
warehousetype
}
'"
;
...
...
AutoTurnOver.Models/dc_auto_config_delivery.cs
0 → 100644
View file @
7791e139
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
AutoTurnOver.Models
{
public
class
dc_auto_config_delivery
{
public
int
id
{
get
;
set
;
}
public
DateTime
gmt_create
{
get
;
set
;
}
public
DateTime
gmt_modified
{
get
;
set
;
}
public
string
variable_code
{
get
;
set
;
}
public
string
variable_name
{
get
;
set
;
}
/// <summary>
/// 类型(1.SKU ,2.分类 3. 仓库计算)
/// </summary>
public
int
type
{
get
;
set
;
}
public
string
bl_operator
{
get
;
set
;
}
public
string
remark
{
get
;
set
;
}
/// <summary>
/// 1启用, 2停用
/// </summary>
public
int
status
{
get
;
set
;
}
/// <summary>
/// 调拨打包
/// </summary>
public
decimal
tranfer_bale
{
get
;
set
;
}
/// <summary>
/// 调拨头程
/// </summary>
public
decimal
tranfer_head
{
get
;
set
;
}
/// <summary>
/// 调拨入库
/// </summary>
public
decimal
abroad_inbound
{
get
;
set
;
}
}
public
class
dc_auto_config_delivery_dto
:
dc_auto_config_delivery
{
public
string
type_str
{
get
{
return
((
type_enum
)
type
).
ToString
();
}
}
public
enum
type_enum
{
SKU
=
1
,
产品分类
=
2
,
仓库
=
3
}
}
}
AutoTurnOver.Models/dc_auto_turnover.cs
View file @
7791e139
...
...
@@ -172,6 +172,16 @@ namespace AutoTurnOver.Models
/// </summary>
public
decimal
average_overdue
{
get
;
set
;
}
/// <summary>
/// 调拨打包天数
/// </summary>
public
decimal
transfer_bale_delivery
{
get
;
set
;
}
/// <summary>
/// 海外仓入库天数
/// </summary>
public
decimal
abroad_inbound_delivery
{
get
;
set
;
}
}
public
class
Condition_AutoTurnOver
...
...
@@ -199,6 +209,11 @@ namespace AutoTurnOver.Models
public
string
warehousetype
{
get
;
set
;
}
public
int
?
warehousearea
{
get
;
set
;
}
/// <summary>
/// 是否有配置缺失
/// </summary>
public
bool
?
hasDefectConfig
{
get
;
set
;
}
}
public
class
dc_auto_turnover_Extend
:
dc_auto_turnover
...
...
AutoTurnOver.Services/ConfigServices.cs
View file @
7791e139
...
...
@@ -126,7 +126,7 @@ namespace AutoTurnOver.Services
#
endregion
#
region
安全库存
规则配置
#
region
销量上限
规则配置
/// <summary>
/// 获取安全库存规则设置分页列表
...
...
@@ -248,5 +248,102 @@ namespace AutoTurnOver.Services
}
#
endregion
#
region
供应链长度规则配置
/// <summary>
/// 获取供应链长度规则设置分页列表
/// </summary>
/// <param name="m"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public
List
<
dc_auto_config_delivery_dto
>
ConfigDeliveryList
(
Condition_ConfigPromotion
m
,
int
offset
,
int
limit
,
ref
int
total
)
{
return
DB
.
db_config
.
ConfigDeliveryList
(
m
,
offset
,
limit
,
ref
total
);
}
/// <summary>
/// 保存安全库存规则
/// </summary>
/// <param name="m">销售设置model</param>
/// <param name="username">当前操作人</param>
/// <returns></returns>
public
string
SaveConfigDelivery
(
Models
.
dc_auto_config_delivery
m
,
string
username
)
{
if
(
m
.
tranfer_bale
<=
0
)
{
return
"调拨打包天数必填!"
;
}
if
(
m
.
tranfer_head
<=
0
)
{
return
"调拨头程天数必填!"
;
}
if
(
m
.
abroad_inbound
<=
0
)
{
return
"海外仓入库天数必填!"
;
}
if
(
m
.
type
==
(
int
)
dc_auto_config_delivery_dto
.
type_enum
.
仓库
)
{
if
(
string
.
IsNullOrWhiteSpace
(
m
.
variable_code
))
{
return
"仓库不能为空!"
;
}
var
objWarehouse
=
DB
.
common
.
GetWareHouseByCode
(
m
.
variable_code
);
if
(
objWarehouse
==
null
)
{
return
"系统找不到该仓库。"
;
}
m
.
variable_name
=
objWarehouse
.
warehouse_name
;
}
else
if
(
m
.
type
==
(
int
)
dc_auto_config_delivery_dto
.
type_enum
.
产品分类
)
{
if
(
string
.
IsNullOrWhiteSpace
(
m
.
variable_code
))
{
return
"请选择分类"
;
}
var
cID
=
0
;
if
(!
int
.
TryParse
(
m
.
variable_code
,
out
cID
))
{
return
"请选择分类"
;
}
var
cModel
=
ApiServices
.
GetCategoryById
(
cID
);
m
.
variable_name
=
cModel
.
C_CNAME
;
}
else
if
(
m
.
type
==
(
int
)
dc_auto_config_delivery_dto
.
type_enum
.
SKU
)
{
if
(
string
.
IsNullOrWhiteSpace
(
m
.
variable_code
))
{
return
"Sku不能为空!"
;
}
var
objProduct
=
DB
.
common
.
GetPrductBySku
(
m
.
variable_code
);
if
(
objProduct
==
null
)
{
return
"系统找不到该Sku。"
;
}
m
.
variable_name
=
objProduct
.
sku_title_cn
;
}
return
DB
.
db_config
.
SaveConfigDelivery
(
m
,
username
);
}
/// <summary>
/// 获取安全库存规则设置详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
dc_auto_config_delivery
GetConfigDeliveryById
(
int
id
)
{
return
DB
.
db_config
.
GetConfigDeliveryById
(
id
);
}
#
endregion
}
}
AutoTurnOver/Controllers/ConfigController.cs
View file @
7791e139
...
...
@@ -137,5 +137,68 @@ namespace AutoTurnOver.Controllers
}
#
endregion
#
region
供应链长度规则
/// <summary>
/// 获取供应链长度列表
/// </summary>
/// <param name="limit">每页记录数</param>
/// <param name="offset">偏移量</param>
/// <param name="order">排序字段</param>
/// <param name="sort">升序还是降序</param>
/// <param name="sku">sku编码</param>
/// <param name="warehousecode">仓库编码</param>
/// <param name="IsEffective">是否有效数据</param>
/// <returns></returns>
[
HttpGet
]
public
JsonResult
ConfigDeliveryList
(
int
limit
,
int
offset
,
string
order
,
string
sort
,
string
sku
,
string
warehousecode
,
string
warehousetype
,
int
?
warehousearea
,
bool
?
IsEffective
=
null
)
{
var
m
=
new
Condition_ConfigPromotion
{
sku
=
sku
,
warehousecode
=
warehousecode
,
IsEffective
=
IsEffective
,
warehousetype
=
warehousetype
,
warehousearea
=
warehousearea
};
var
total
=
0
;
var
service
=
new
Services
.
ConfigServices
();
var
list
=
service
.
ConfigDeliveryList
(
m
,
offset
,
limit
,
ref
total
);
return
new
JsonResult
(
new
{
rows
=
list
,
total
=
total
,
});
}
/// <summary>
/// 保存供应链长度规则设置
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
JsonResult
SaveConfigDelivery
([
FromBody
]
dc_auto_config_delivery
m
)
{
var
result
=
new
Services
.
ConfigServices
().
SaveConfigDelivery
(
m
,
""
);
return
new
JsonResult
(
result
);
}
/// <summary>
/// 获取供应链长度规则设置详情
/// </summary>
/// <param name="id">销售设置id</param>
/// <returns></returns>
[
HttpGet
]
public
JsonResult
GetConfigDeliveryById
(
int
id
)
{
var
m
=
new
Services
.
ConfigServices
().
GetConfigDeliveryById
(
id
);
return
new
JsonResult
(
m
);
}
#
endregion
}
}
\ No newline at end of file
AutoTurnOver/Controllers/ReportsController.cs
View file @
7791e139
...
...
@@ -58,7 +58,8 @@ namespace AutoTurnOver.Controllers
nowShortage
=
int
.
Parse
(
result
[
3
].
Split
(
','
)[
7
]),
// 今天的实际缺货
cumulativeShortageDate
=
turnoverDate
.
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
),
// 一直到周转期前一天的日期
cumulativeShortage
=
int
.
Parse
(
result
[
3
].
Split
(
','
)[
turnoverData
.
turnover_days
+
7
-
1
]),
// 一直到周转期前一天的累计缺货
average_overdue
=
Math
.
Max
(
0
,
turnoverData
.
average_overdue
)
average_overdue
=
Math
.
Max
(
0
,
turnoverData
.
average_overdue
),
nowDateStock
=
int
.
Parse
(
result
[
2
].
Split
(
','
)[
7
])
// 今天的预测库存
};
return
new
JsonResult
(
new
...
...
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