Browse Source

Merge branch 'master' of http://code.qiyue666.com/pengcong001/bbwy

AddValidOverTime
shanji 2 years ago
parent
commit
13ef69c715
  1. 2
      BBWY.Client/GlobalContext.cs
  2. 15
      BBWY.Client/Helpers/MyPrintHelper.cs
  3. 5
      BBWY.Client/Models/APIModel/Request/CerRequest.cs
  4. 6
      BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs
  5. 15
      BBWY.Client/Models/Enums.cs
  6. 16
      BBWY.Client/Models/PackTask/CertificateModel.cs
  7. 11
      BBWY.Client/Models/PackTask/PackTaskModel.cs
  8. 111
      BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs
  9. 2
      BBWY.Client/Views/PackTask/LookCerWindow.xaml
  10. 12
      BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs
  11. 100
      BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs
  12. 2
      BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs
  13. 5
      BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs
  14. 8
      BBWY.Client/Views/QualityTask/QualityWindow.xaml

2
BBWY.Client/GlobalContext.cs

@ -9,7 +9,7 @@ namespace BBWY.Client
{
ShopServiceGroupList = new List<string>();
ShopServiceGroupLowerList = new List<string>();
ClientVersion = "10122";
ClientVersion = "10125";
}
private User user;

15
BBWY.Client/Helpers/MyPrintHelper.cs

@ -9,6 +9,7 @@ using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Media.Imaging;
using WebSocketSharp;
@ -618,5 +619,19 @@ namespace BBWY.Client.Helpers
}
}
public static void SetDefaultPrint(string printName)
{
SetDefaultPrinter(printName);
}
/// <summary>
/// 调用win api将指定名称的打印机设置为默认打印机
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
[DllImport("winspool.drv")]
public static extern bool SetDefaultPrinter(string Name);
}
}

5
BBWY.Client/Models/APIModel/Request/CerRequest.cs

@ -68,11 +68,14 @@ namespace BBWY.Client.Models.APIModel.Request
/// </summary>
public string ApplyAge { get; set; }
public int GoodsNumber { get; set; }
public long GoodsNumber { get; set; }
public string ProduceDate { get; set; }
public string PurchaseSkuId { get; set; }
public SaveType? SaveType { get; set; }
}
}

6
BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs

@ -93,6 +93,12 @@ namespace BBWY.Client.Models.APIModel.Response.PackPurchaseTask
/// 配件列表
/// </summary>
public PurchaseSku[] PurchaseSkus { get; set; }
/// <summary>
///
/// </summary>
public SaveType? SaveType { get; set; }
}
public class WareHourseDTO
{

15
BBWY.Client/Models/Enums.cs

@ -452,4 +452,19 @@
{
= 0, = 1/*,其他=2//基础包装 增量配件*/
}
/// <summary>
/// 打包配置存放区分
/// </summary>
public enum SaveType
{
/// <summary>
/// c端
/// </summary>
C端 = 0,
/// <summary>
/// B端
/// </summary>
B端 = 1
}
}

16
BBWY.Client/Models/PackTask/CertificateModel.cs

@ -12,9 +12,6 @@ namespace BBWY.Client.Models
/// 合格证id
/// </summary>
public long Id { get; set; }
/// <summary>
/// skuid
/// </summary>
@ -142,11 +139,20 @@ namespace BBWY.Client.Models
private int goodsNumber = 1;
private long goodsNumber = 1;
/// <summary>
/// 配件序号
/// </summary>
public long GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
private int goodsNumberIndex = 1;
/// <summary>
/// 配件序号
/// </summary>
public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
public int GoodsNumberIndex { get => goodsNumberIndex; set { Set(ref goodsNumberIndex, value); } }
private string produceDate;
/// <summary>

11
BBWY.Client/Models/PackTask/PackTaskModel.cs

@ -103,7 +103,16 @@ namespace BBWY.Client.Models
// qualityViewModel.TaskId = TaskId;
qualityViewModel.OrderId = OrderId;
qualityViewModel.SkuId = SkuId;
qualityViewModel.SearchSku(this);
try
{
qualityViewModel.SearchSku(this);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
//qualityViewModel.LoadPackDatas();
//qualityViewModel.SetAllFees = new Action<FeesItemResponse, List<string>>((feesItem, packUsers) =>
//{

111
BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs

@ -20,6 +20,7 @@ using Org.BouncyCastle.Asn1.Crmf;
using System.Runtime.InteropServices.WindowsRuntime;
using NPOI.Util;
using BBWY.Controls;
using WebSocketSharp;
namespace BBWY.Client.ViewModels
{
@ -445,20 +446,20 @@ namespace BBWY.Client.ViewModels
};
if (IsNeedBarCode == Need.)
{
if (BarCodeModel==null|| BarCodeModel.Id <= 0)
if (BarCodeModel == null || BarCodeModel.Id <= 0)
{
MessageBox.Show("条形码不能为空");
return;
}
request.BarcodeId = BarCodeModel.Id;
}
if (IsNeedCertificateModel == Need.)
if(PurchaseSkuList != null && PurchaseSkuList.Count > 0&&purchaseSkuList.Any(p=> p.IsNeedCer)) //(IsNeedCertificateModel == Need.需要)
{
if (PurchaseSkuList == null && PurchaseSkuList.Count <= 0)
{
MessageBox.Show("无可用的合格证打印!");
return;
}
//if ()
//{
// MessageBox.Show("无可用的合格证打印!");
// return;
//}
if (PurchaseSkuList.Where(p => p.IsSetCertificate).Count() > 0)
{
MessageBox.Show("存在未确认的合格证,请先完成确认!");
@ -506,7 +507,7 @@ namespace BBWY.Client.ViewModels
if (competeTime<DateTime.Now)
if (competeTime < DateTime.Now)
{
MessageBox.Show($"预计完成时间不能小于当前时间,请重新选择预计完成时间");
return;
@ -516,7 +517,7 @@ namespace BBWY.Client.ViewModels
var now = DateTime.Now;
if (now.Hour < 12)
{
if (competeTime> now.AddDays(1).Date.AddHours(12))
if (competeTime > now.AddDays(1).Date.AddHours(12))
{
MessageBox.Show($"预计完成时间不能超过明天12点,请重新选择预计完成时间");
return;
@ -552,28 +553,40 @@ namespace BBWY.Client.ViewModels
request.PreCompeteTime = competeTime;
var competeRes = packPurchaseTaskService.CompeteQualityTask(request);
if (competeRes == null)
{
MessageBox.Show("网络异常");
return;
}
if (!competeRes.Success)
try
{
MessageBox.Show(competeRes.Msg);
return;
}
BatchPrintWindow batchPrint = new BatchPrintWindow();
var competeRes = packPurchaseTaskService.CompeteQualityTask(request);
if (competeRes == null)
{
MessageBox.Show("网络异常");
return;
}
if (!competeRes.Success)
{
MessageBox.Show(competeRes.Msg);
return;
}
BatchPrintWindow batchPrint = new BatchPrintWindow();
batchPrint.SetData(GoodProductQuantity,
PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray()
, BarCodeModel);
batchPrint.ShowDialog();
batchPrint.SetData(GoodProductQuantity,
PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray()
, BarCodeModel);
batchPrint.ShowDialog();
if (ReflashWindow != null) ReflashWindow();
var window = obj as BWindow;
if (ReflashWindow != null) ReflashWindow();
var window = obj as BWindow;
App.Current.Dispatcher.Invoke(new Action(() =>
{
window.Close();
}));
}
catch (Exception ex)
{
window.Close();
System.Windows.MessageBox.Show(ex.Message);
}
}
@ -638,7 +651,7 @@ namespace BBWY.Client.ViewModels
model.CerDTO.BrandName = BrandName;
QualitySetCerWindow setCerWindow = new QualitySetCerWindow();
setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate);
setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate, saveType);
setCerWindow.SaveResult = (s, PackCerState) =>
{
if (string.IsNullOrEmpty(s.PurchaseSkuId))
@ -679,6 +692,9 @@ namespace BBWY.Client.ViewModels
look.Show();
}
SaveType? saveType;
/// <summary>
/// 搜索 skuId(todo:)
/// </summary>
@ -702,6 +718,7 @@ namespace BBWY.Client.ViewModels
BasicPack = model.BasicPack;
CertificatePosition = model.CertificatePosition;
ArrivalQuantity = 0;
GoodProductQuantity = 0;
@ -728,10 +745,30 @@ namespace BBWY.Client.ViewModels
var packTaskRes = packPurchaseTaskService.GetQualityTask(model.TaskId);
if (packTaskRes==null)
{
MessageBox.Show("网络异常!");
return;
}
if (!packTaskRes.Success || packTaskRes.Data==null)
{
MessageBox.Show(packTaskRes.Msg);
return;
}
SkuPurchaseSchemeId = packTaskRes.Data.SkuPurchaseSchemeId;
saveType = packTaskRes.Data.SaveType;
if (saveType == null)
{
saveType = OrderId.IsNullOrEmpty() ? SaveType.C端 : SaveType.B端;
}
if (packTaskRes == null || !packTaskRes.Success) return;
BarCodeModel = packTaskRes.Data.BarCodeDTO;
IsNeedBarCode = packTaskRes.Data.IsNeedBar ? Need. : Need.;
IsSetBarCode = packTaskRes.Data.IsNeedBar ? false : true;
IsSetBarCode = packTaskRes.Data.BarCodeDTO == null ? true : false;
IsNeedCertificateModel = packTaskRes.Data.IsNeedCer ? Need. : Need.;
if (packTaskRes.Data.WareHourses != null)
packTaskRes.Data.WareHourses.ToList().ForEach(w =>
@ -742,9 +779,11 @@ namespace BBWY.Client.ViewModels
if (packTaskRes.Data.PurchaseSkus != null)
{
int goodsIndex = 0;
foreach (var item in packTaskRes.Data.PurchaseSkus)
{
goodsIndex++;
if (item.CerDTO != null) item.CerDTO.GoodsNumberIndex = goodsIndex;
item.IsSetCertificate = true;
if (string.IsNullOrEmpty(item.PurchaseProductId))
{
@ -756,14 +795,16 @@ namespace BBWY.Client.ViewModels
{
PurchaseSkuList.Add(item); continue;
}
PurchaseSkuItemBasicInfoResponse skuItem = null;
if (list.Data != null) skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
var skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
App.Current.Dispatcher.Invoke(new Action(() =>
{
PurchaseSkuList.Add(new PurchaseSku
{
Logo = skuItem.Logo,
Title = skuItem.Title,
Logo = skuItem?.Logo,
Title = skuItem?.Title,
IsNeedCer = item.IsNeedCer,
PurchaseSkuId = item.PurchaseSkuId,
CerDTO = item.CerDTO,
@ -806,7 +847,7 @@ namespace BBWY.Client.ViewModels
if (hour<12)
if (hour < 12)
{
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");
@ -815,7 +856,7 @@ namespace BBWY.Client.ViewModels
PreCompeteTimeHour = "12点前";
}
else if (hour<18)
else if (hour < 18)
{
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");

2
BBWY.Client/Views/PackTask/LookCerWindow.xaml

@ -44,7 +44,7 @@
</hc:TabControl.Resources>
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center" Text="{Binding CertificateModel.GoodsNumber,StringFormat=配件{0}}"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding CertificateModel.GoodsNumberIndex,StringFormat=配件{0}}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>

12
BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs

@ -29,11 +29,23 @@ namespace BBWY.Client.Views.PackTask
InitializeComponent();
GoodsNumberCerList = new ObservableCollection<GoodsNumberCer>();
int goodsNumberIndex = 0;
foreach (CertificateModel certificateModel in certificate)
{
if (certificateModel==null)
{
continue;
}
goodsNumberIndex++;
certificateModel.GoodsNumberIndex = goodsNumberIndex;
GoodsNumberCerList.Add(new GoodsNumberCer
{
CertificateModel = certificateModel.Copy(),
});
}
this.DataContext = this;
}

100
BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs

@ -1,5 +1,6 @@
using BarcodeLib;
using BBWY.Client.APIServices;
using BBWY.Client.Helpers;
using BBWY.Client.ViewModels;
using BBWY.Client.ViewModels.PackTask;
using BBWY.Controls;
@ -50,9 +51,8 @@ namespace BBWY.Client.Views.PackTask
MessageBox.Show("打印机处于错误状态");
return;
}
//Print(this.printArea, cbPrintName.Text, "打印任务",1);
MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机
this.printArea.Arrange(new Rect(new Point(0, 0), new Size(printArea.ActualWidth, printArea.ActualHeight)));
PrintDialog printDialog = new PrintDialog();
@ -76,99 +76,7 @@ namespace BBWY.Client.Views.PackTask
/// <summary>
/// 打印
/// </summary>
/// <param name="document">流文档</param>
/// <param name="printer">打印机名称</param>
/// <param name="description">打印描述</param>
/// <param name="copyCount">打印个数</param>
public static void Print(Visual document, string printer, string description, int copyCount)
{
var localPrintServer = new LocalPrintServer();
var printQueue = localPrintServer.GetPrintQueue(printer);
if (printQueue.IsInError)
{
throw new Exception("打印机处于错误状态");
}
var printDialog = new PrintDialog
{
PrintQueue = printQueue, //打印队列
PrintTicket = { CopyCount = copyCount } //打印个数
};
//设置纸张大小
var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); //小标签:114
var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); //小标签:227
printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight);
//设置纸张边距
var paperSize = GetPaperSize(printer); //小标签:118*246
//var offsetX = (int)Math.Ceiling((paperSize.Width - pageWidth) / 2f);
//var offsetY = (int)Math.Ceiling((paperSize.Height - pageHeight) / 2f);
//document.PagePadding = new Thickness(offsetX, offsetY, offsetX, offsetY);
//打印
var paginator = ((IDocumentPaginatorSource)document).DocumentPaginator;
printDialog.PrintDocument(paginator, description);
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string printNames = System.IO.Path.Combine(applicationPath, "printName.init");
File.WriteAllText(printNames, printer);
}
private static object GetPaperSize(string printer)
{
return null;
}
public interface IDocumentRenderer
{
void Render(FlowDocument doc, object data);
}
public class CommonDocumentRenderer : IDocumentRenderer
{
public void Render(FlowDocument doc, object data)
{
var model = data as PrintModel;
if (model == null)
{
throw new ArgumentException("data is not PrintModel");
}
var type = typeof(PrintModel);
var properties = type.GetProperties();
foreach (var property in properties)
{
//文本赋值
if (doc.FindName(property.Name) is TextBlock textBlock)
{
textBlock.Text = property.GetValue(model)?.ToString();
}
}
}
}
public class PrintModel
{
/// <summary>
/// 批号
/// </summary>
public string BatchNumber { get; set; }
/// <summary>
/// 订单号
/// </summary>
public string OrderNumber { get; set; }
/// <summary>
/// 物料代码
/// </summary>
public string MaterialNumber { get; set; }
}
}
}

2
BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs

@ -139,7 +139,7 @@ namespace BBWY.Client.Views.PackTask
setSpuCerWindow.Show();
}
int selectCer = -1;//tabcontrol 选中事件
long selectCer = -1;//tabcontrol 选中事件
private void InseartCer_Click(object sender, RoutedEventArgs e)
{
if (IsSetSpuCertificate)

5
BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs

@ -35,14 +35,16 @@ namespace BBWY.Client.Views.QualityTask
PackCerState = obj;
}
public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate)
public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate,SaveType? saveType)
{
this.CertificateModel = CertificateModel.Copy();
this.packTaskService = packTaskService;
PackCerState = isNeedCer ? PackCerState. : PackCerState.;
SaveType = saveType;
this.DataContext = this;
}
public SaveType? SaveType { get; set; }
public ICommand SetPackCerStateCommand { get; set; }
@ -123,6 +125,7 @@ namespace BBWY.Client.Views.QualityTask
GoodsNumber = CertificateModel.GoodsNumber,
ProduceDate = CertificateModel.ProduceDate,
PurchaseSkuId = CertificateModel.PurchaseSkuId,
SaveType = SaveType
});
if (resData == null || !resData.Success)
{

8
BBWY.Client/Views/QualityTask/QualityWindow.xaml

@ -212,7 +212,7 @@
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"
BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"
Foreground="{StaticResource Text.Color}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@ -316,7 +316,7 @@
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}"
BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}"
Foreground="{StaticResource Text.Color}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@ -331,7 +331,7 @@
<Border Margin="20 0 0 0" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" Height="150" Width="150">
<StackPanel Orientation="Vertical">
<Border BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" Height="30 " Margin="10 50 10 30">
<TextBlock Text="{Binding CerDTO.GoodsNumber,StringFormat=配件{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding CerDTO.GoodsNumberIndex,StringFormat=配件{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
@ -395,7 +395,7 @@
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="86"/>
<ColumnDefinition Width="86"/>
<ColumnDefinition Width="0" />
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>

Loading…
Cancel
Save