CarTaskMaintainVM.cs
5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using HHECS.Application.Enums;
using HHECS.BllModel;
using HHECS.Infrastructure.CommonHelper;
using HHECS.Model.Entities;
using HHECS.Model.Enums.Car;
using HHECS.Model.Enums.Task;
using HHECS.WinCommon.ViewModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Windows;
using MessageBox = HandyControl.Controls.MessageBox;
namespace HHECS.WinClient.View.TaskInfo
{
public class CarTaskMaintainVM : VMBase
{
public string Id { get; set; }
public string StepTraceId { get; set; }
public string WorkOrderHeadId { get; set; }
public string CarNo { get; set; }
public string FromLocation { get; set; }
public string ToLocation { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public Dictionary<string, object> Types { get; set; }
public Dictionary<string, object> Statuss { get; set; }
public CarTaskMaintainVM(int id)
{
Id = id.ToString();
var type = EnumHelper.EnumListDicString<CutPlanHeadState>("全部", "");
Types = type;
var statu = EnumHelper.EnumListDicString<CutPlanHeadState>("全部", "");
Statuss = statu;
}
public Expression<Func<TaskCarEntity, bool>> GetCarTaskMaintainExpression()
{
Expression<Func<TaskCarEntity, bool>> filter = a => true;
if (!string.IsNullOrWhiteSpace(Id))
{
filter = filter.And(a => a.Id.ToString() == Id);
}
if (!string.IsNullOrWhiteSpace(WorkOrderHeadId))
{
filter = filter.And(a => a.StepTraceId.ToString() == WorkOrderHeadId);
}
if (!string.IsNullOrWhiteSpace(CarNo))
{
filter = filter.And(a => a.CarNo == CarNo);
}
if (!string.IsNullOrWhiteSpace(FromLocation.ToString()))
{
filter = filter.And(a => a.FromLocation.ToString() == FromLocation);
}
if (!string.IsNullOrWhiteSpace(ToLocation.ToString()))
{
filter = filter.And(a => a.ToLocation.ToString() == ToLocation);
}
return filter;
}
public void EditFromLocation()
{
if (string.IsNullOrWhiteSpace(FromLocation))
{
MessageBox.Show("不允许对源库位进行清空处理");
}
else
{
if (MessageBox.Show($"是否更改源库位?", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
var fromlocaiotnCode = Convert.ToInt32(FromLocation);
BllResult result = App.TaskService.UpdateTaskCarFromLocationCode(Convert.ToInt32(Id), fromlocaiotnCode, App.User.UserCode);
if (result.Success)
{
MessageBox.Show("更改源库位成功");
}
else
{
MessageBox.Show($"更改源库位失败:{result.Msg}");
}
}
}
}
public void EditToLocation()
{
if (MessageBox.Show($"是否更改目标库位?", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
var locaiotnCode = ToLocation;
BllResult result = App.TaskService.UpdateTaskCarToLocation(Convert.ToInt32(Id), locaiotnCode, App.User.UserCode);
if (result.Success)
{
MessageBox.Show("更改目标库位成功");
}
else
{
MessageBox.Show($"更改目标库位失败:{result.Msg}");
}
}
}
public void EditStatus()
{
var id = Convert.ToInt32(Id);
if (string.IsNullOrWhiteSpace(Status))
{
MessageBox.Show("请先选中需要更改的状态");
}
else
{
if (Enum.TryParse(Status, out CutPlanHeadState s))
{
if (Status == CutPlanHeadState.接口冻结.GetIndexString())
{
MessageBox.Show("无法维护成任务完成,请使用强制任务完成");
}
else
{
BllResult result = App.TaskService.ChangeTaskCarStatus(id, (int)s, App.User.UserCode);
if (result.Success)
{
MessageBox.Show($"更改任务{id}状态成功");
}
else
{
MessageBox.Show($"更改任务{id}状态失败:{result.Msg}");
}
}
}
else
{
MessageBox.Show($"状态:{Status}无效");
}
}
}
}
}