diff --git a/src/Coldairarrow.Api/Controllers/HuiYan/pricetasklogController.cs b/src/Coldairarrow.Api/Controllers/HuiYan/pricetasklogController.cs
index 0f10bbc..aeca41b 100644
--- a/src/Coldairarrow.Api/Controllers/HuiYan/pricetasklogController.cs
+++ b/src/Coldairarrow.Api/Controllers/HuiYan/pricetasklogController.cs
@@ -144,5 +144,16 @@ namespace Coldairarrow.Api.Controllers.HuiYan
{
return _pricetasklogBus.GetTaskCount();
}
+
+ ///
+ /// 接取任务
+ ///
+ ///
+ ///
+ [HttpPost]
+ public AjaxResult AcceptTask(string teamItemId)
+ {
+ return _pricetasklogBus.AcceptTask(teamItemId);
+ }
}
}
\ No newline at end of file
diff --git a/src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs b/src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs
index 98920b0..ad599a1 100644
--- a/src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs
+++ b/src/Coldairarrow.Api/Controllers/HuiYan/teamitemsController.cs
@@ -129,5 +129,7 @@ namespace Coldairarrow.Api.Controllers.HuiYan
{
return _teamitemsBus.GetMyTaskInfo(type, start, end);
}
+
+
}
}
\ No newline at end of file
diff --git a/src/Coldairarrow.Business/HuiYan/pricetasklogBusiness.cs b/src/Coldairarrow.Business/HuiYan/pricetasklogBusiness.cs
index 7bbd2d6..e7cb8ec 100644
--- a/src/Coldairarrow.Business/HuiYan/pricetasklogBusiness.cs
+++ b/src/Coldairarrow.Business/HuiYan/pricetasklogBusiness.cs
@@ -138,82 +138,6 @@ namespace Coldairarrow.Business.HuiYan
CheckIsTimeOut();
- var users = _iuserBusiness.GetPriceTaskUserList().ToList();
-
- Expression> select = (a, b) => new PricetaskUser()
- {
- UserName = a.UserName,
- MaxTaskCount = a.MaxPriceTaskCount,
- Uid = a.Id
- };
-
- select = select.BuildExtendSelectExpre();
-
- var q_User = Db.GetIQueryable().Where(c => c.CreateTime.Date == DateTime.Now.Date || c.CreateTime == DateTime.MinValue);
-
- var q = from a in users
- join b in q_User on a.Id equals b.UserId into ab
- from b in ab.DefaultIfEmpty()
- select @select.Invoke(a, b);
-
-
- var userList = q.GroupBy(c => c.Uid).Where(c => c.Count() < c.FirstOrDefault()?.MaxTaskCount).Select(c => new PriceUserCount(c.Key, c.Count(), c.Max(c => c.MaxTaskCount) ?? 30)).ToList();
-
-
- var teamItemList = Db.GetIQueryable().Where(c => c.State == (int)TeamItemState.已发布比价 && string.IsNullOrEmpty(c.PriceTaskUserId)).ToList();
-
-
-
- var result = Db.RunTransaction(() =>
- {
-
- List pricetasklogs = new List();
-
- teamItemList.ForEach(teamItem =>
- {
- var user = userList.Where(c => c.Count < c.MaxCount).OrderBy(c => c.Count).FirstOrDefault();
-
- if (user == null)
- {
- return;
- }
-
- teamItem.PriceTaskUserId = user.UserId;
-
- user.Count += 1;
-
- pricetasklogs.Add(new pricetasklog()
- {
- CreateTime = DateTime.Now,
- Id = IdHelper.GetId(),
- CreatorId = _operator.UserId,
- Deleted = false,
- ItemId = teamItem.ItemId,
- UserId = user.UserId,
- State = PriceTaskState.待比价,
- TeamItemId = teamItem.Id
- });
-
- });
-
- int row = Db.Insert(pricetasklogs);
- if (row <= 0)
- {
- throw new Exception("执行定时任务分配错误!");
- }
- row = Db.Update(teamItemList, new List() { "PriceTaskUserId" });
- if (row <= 0)
- {
- throw new Exception("执行定时任务分配更新任务信息错误!");
- }
- });
-
-
- if (!result.Success)
- {
- DingHelper.DingApiHelper.Main.SendNotify("齐越慧眼比价系统任务分配异常!");
- }
-
return Success("任务分配成功!");
}
@@ -289,86 +213,74 @@ namespace Coldairarrow.Business.HuiYan
return Error("任务不存在!");
}
- var users = _iuserBusiness.GetPriceTaskUserList().ToList();
-
- Expression> select = (a, b) => new PricetaskUser()
+ var result = Db.RunTransaction(() =>
{
- UserName = a.UserName,
- MaxTaskCount = a.MaxPriceTaskCount,
- Uid = a.Id
- };
-
- select = select.BuildExtendSelectExpre();
-
- var q_User = Db.GetIQueryable().Where(c => c.CreateTime.Date == DateTime.Now.Date || c.CreateTime == DateTime.MinValue);
+ int row = Db.Update(c => c.Id == teamItem.Id, (item) =>
+ {
+ item.State = (int)TeamItemState.已发布比价;
+ item.PriceTaskCreateDate = DateTime.Now;
+ });
- var q = from a in users
- join b in q_User on a.Id equals b.UserId into ab
- from b in ab.DefaultIfEmpty()
- select @select.Invoke(a, b);
+ if (row <= 0)
+ throw new Exception("系统繁忙!");
- //获取当日可分配的一个用户
- var user = q.GroupBy(c => c.Uid).Where(c => c.Count() < c.FirstOrDefault()?.MaxTaskCount).Select(c => new { Id = c.Key, Count = c.Count() }).OrderBy(c => c.Count).FirstOrDefault();
+ });
- if (user == null)
+ if (result.Success)
{
+ return Success("发布任务成功!");
+ }
- DingHelper.DingApiHelper.Main.SendNotify("齐越慧眼比价系统任务量已达上限!");
+ return Error(result.ex.Message);
+ }
- //钉钉推送
- // return Error("当前任务量已超过任务池可用任务量!");
- }
+ public AjaxResult AcceptTask(string teamItemId)
+ {
+ var teamItem = Db.GetIQueryable().FirstOrDefault(c => c.Id == teamItemId);
+ if (teamItem == null)
+ {
+ return Error("任务不存在!");
+ }
var result = Db.RunTransaction(() =>
{
- int row = Db.Update(c => c.Id == teamItem.Id, (item) =>
+ var price = new pricetasklog()
{
- if (user != null)
- {
- item.PriceTaskUserId = user.Id;
- }
- else {
- item.PriceTaskUserId = null;
- }
+ CreateTime = DateTime.Now,
+ Id = IdHelper.GetId(),
+ CreatorId = _operator.UserId,
+ Deleted = false,
+ ItemId = teamItem.ItemId,
+ UserId = _operator.UserId,
+ State = PriceTaskState.待比价,
+ TeamItemId = teamItem.Id
+ };
+
+ int row = Db.Insert(price);
- item.State = (int)TeamItemState.已发布比价;
+ if (row <= 0)
+ throw new Exception("任务已被接取!");
+
+ row = Db.Update(c => c.Id == teamItem.Id, (item) =>
+ {
+ item.PriceTaskUserId =_operator.UserId;
});
if (row <= 0)
throw new Exception("系统繁忙!");
- if (user != null)
- {
- row = Db.Insert(new pricetasklog()
- {
- CreateTime = DateTime.Now,
- Id = IdHelper.GetId(),
- CreatorId = _operator.UserId,
- Deleted = false,
- ItemId = teamItem.ItemId,
- UserId = user.Id,
- State = PriceTaskState.待比价,
- TeamItemId = teamItem.Id
- });
-
- if (row <= 0)
- throw new Exception("系统任务繁忙!");
- }
-
});
if (result.Success)
{
- return Success("发布任务成功!");
+ return Success("接取任务成功!");
}
return Error(result.ex.Message);
}
-
-
public AjaxResult SetState(string id, int state)
{
diff --git a/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs b/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs
index eac8d31..a1ce396 100644
--- a/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs
+++ b/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs
@@ -125,6 +125,19 @@ namespace Coldairarrow.Business.HuiYan
where = where.And(c => c.State == state);
}
}
+
+
+ if (state == 4)
+ {
+ var task = q.Where(c=> c.State == (int)TeamItemState.已发布比价&&string.IsNullOrEmpty(c.PriceTaskUserId)).OrderBy(c=>c.PriceTaskCreateDate).FirstOrDefault();
+
+ List result= new List();
+ if (task != null)
+ {
+ result.Add(task);
+ }
+ return new PageResult() { Data = result, Total = 1, Success = true };
+ }
}
where = where.AndIf(!string.IsNullOrEmpty(keyWord), d => string.IsNullOrEmpty(d.CatName) ? true : d.CatName.Contains(keyWord));
diff --git a/src/Coldairarrow.Entity/HuiYan/teamitems.cs b/src/Coldairarrow.Entity/HuiYan/teamitems.cs
index e405f10..7f3b1f5 100644
--- a/src/Coldairarrow.Entity/HuiYan/teamitems.cs
+++ b/src/Coldairarrow.Entity/HuiYan/teamitems.cs
@@ -125,5 +125,9 @@ namespace Coldairarrow.Entity.HuiYan
/// 完成时间
///
public DateTime? UpdateDate { get; set; }
+ ///
+ /// 比价发布日期
+ ///
+ public DateTime? PriceTaskCreateDate { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Coldairarrow.IBusiness/HuiYan/IpricetasklogBusiness.cs b/src/Coldairarrow.IBusiness/HuiYan/IpricetasklogBusiness.cs
index a0131a8..786f37a 100644
--- a/src/Coldairarrow.IBusiness/HuiYan/IpricetasklogBusiness.cs
+++ b/src/Coldairarrow.IBusiness/HuiYan/IpricetasklogBusiness.cs
@@ -23,5 +23,7 @@ namespace Coldairarrow.Business.HuiYan
AjaxResult GetMyCount();
AjaxResult DayTaskSet();
+
+ AjaxResult AcceptTask(string teamItemId);
}
}
\ No newline at end of file
diff --git a/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/api/http.js b/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/api/http.js
index f41313c..c0b0c71 100644
--- a/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/api/http.js
+++ b/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/api/http.js
@@ -19,7 +19,7 @@ else if (process.env.NODE_ENV == 'production') {
let ipAddress = axios.defaults.baseURL;
-//axios.defaults.baseURL = 'http://localhost:5000/';
+axios.defaults.baseURL = 'http://localhost:5000/';
//axios.defaults.baseURL = 'http://hyapi.qiyue666.com/';
axios.interceptors.request.use((config) => {
diff --git a/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/pricetask/Index.vue b/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/pricetask/Index.vue
index 2b1ae98..1fbf77c 100644
--- a/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/pricetask/Index.vue
+++ b/客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/pricetask/Index.vue
@@ -1,6 +1,11 @@
-
+
+
+
-
+
@@ -352,7 +357,7 @@
{{
item.Title
}}
-
@@ -424,12 +429,21 @@
@click="setState(item.PriceTaskId, 1)"
>修改完成
+
+
+ 加入待比价
+
0) {
url = "/HuiYan/pricetasklog/GetItems?keyword=" + this.catKeyWord;
}
+ if(type==4)
+ {
+ url='/HuiYan/teamitems/GetItems'
+ }
+
this.http
.post(url, {
PageIndex: this.pagination.current,
@@ -718,6 +737,17 @@ export default {
});
}
},
+ acceptTask(teamItemId){
+ this.http.post(`/HuiYan/pricetasklog/AcceptTask?teamItemId=${teamItemId}`).then((res) => {
+ if (res.Success) {
+ this.$message.success("操作成功!");
+ this.getDatas(this.currentTab);
+ } else {
+ this.$message.error(res.Msg);
+ this.getDatas(this.currentTab);
+ }
+ });
+ },
sendPriceTask(id) {
this.http.post(`/HuiYan/pricetasklog/AddTask?id=${id}`).then((res) => {
if (res.Success) {