|
@@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.Input;
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
using System.Collections.Specialized;
|
|
-using System.ComponentModel;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Data;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Text;
|
|
@@ -103,7 +102,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
|
|
|
private InspectApplyDetail? _selectedDetail;
|
|
private InspectApplyDetail? _selectedDetail;
|
|
|
|
|
|
- private SelectContractDetailModel? _selecteContractDetail;
|
|
|
|
|
|
+ private SelectContractDetailModel? _selectedContractDetail;
|
|
|
|
|
|
private readonly IDataBaseService<SerialNumber> _serialService;
|
|
private readonly IDataBaseService<SerialNumber> _serialService;
|
|
private readonly IDataBaseService<InspectApply> _inspectService;
|
|
private readonly IDataBaseService<InspectApply> _inspectService;
|
|
@@ -133,11 +132,8 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
}
|
|
}
|
|
|
|
|
|
//监管单位简称
|
|
//监管单位简称
|
|
- SupervisionUnit? supervisionUnit = App.CurrentUser!.SupervisionUnit;
|
|
|
|
- if (supervisionUnit != null)
|
|
|
|
- {
|
|
|
|
- SupervisionUnitShortName = supervisionUnit.ShortName;
|
|
|
|
- }
|
|
|
|
|
|
+ var supervisionUnit = App.CurrentUser!.SupervisionUnit;
|
|
|
|
+ SupervisionUnitShortName = supervisionUnit.ShortName;
|
|
|
|
|
|
//默认生产企业
|
|
//默认生产企业
|
|
SelectedCompany = Companies.FirstOrDefault(c => c.Guid == App.CurrentUser.CompanyGuid);
|
|
SelectedCompany = Companies.FirstOrDefault(c => c.Guid == App.CurrentUser.CompanyGuid);
|
|
@@ -174,9 +170,6 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- //生成材料批号:材料企业代码-材料代码-申请检验时间;待修改
|
|
|
|
- //BatchNo = SelectedCompany?.SystemCode + "-" + SelectedMaterial?.VarietyCode + "-" + InspDate.ToString("yyyyMMdd");
|
|
|
|
-
|
|
|
|
if (InspReport == null || InspReport.Length == 0)
|
|
if (InspReport == null || InspReport.Length == 0)
|
|
{
|
|
{
|
|
MessageBox.Show("请上传订购方检测报告!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
MessageBox.Show("请上传订购方检测报告!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
@@ -270,22 +263,6 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
return totalInspectedQty;
|
|
return totalInspectedQty;
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 计算该品种历史累计抽样送检次数
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="year">年度</param>
|
|
|
|
- /// <param name="companyGuid">生产企业</param>
|
|
|
|
- /// <param name="materialGuid">产品</param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- private int CalculateSampleTimes(int year, Guid? companyGuid, Guid? materialGuid)
|
|
|
|
- {
|
|
|
|
- if (companyGuid == null || materialGuid == null) return 0;
|
|
|
|
-
|
|
|
|
- var inspectApplies = _inspectService.Query(x => x.Year == year && x.CompanyGuid == companyGuid && x.MaterialGuid == materialGuid && x.SampleStatus).ToList();
|
|
|
|
-
|
|
|
|
- return inspectApplies.Count;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 生成文档
|
|
/// 生成文档
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -471,7 +448,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
{
|
|
{
|
|
applyDetail.Note = dr["备注"].ToString();
|
|
applyDetail.Note = dr["备注"].ToString();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
InspectApplyDetails.Add(applyDetail);
|
|
InspectApplyDetails.Add(applyDetail);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -485,7 +462,9 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
[RelayCommand]
|
|
[RelayCommand]
|
|
private void ExportDetail()
|
|
private void ExportDetail()
|
|
{
|
|
{
|
|
- InspectApplyUtil.ExportBatchDetail(InspectApplyDetails, SelectedCompany?.Name, SelectedMaterial?.Name, BatchNo);
|
|
|
|
|
|
+ var companyName = SelectedCompany?.Name ?? string.Empty;
|
|
|
|
+ var materialName = SelectedMaterial?.Name ?? string.Empty;
|
|
|
|
+ InspectApplyUtil.ExportBatchDetail(InspectApplyDetails, companyName, materialName, BatchNo);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -529,12 +508,12 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
[RelayCommand]
|
|
[RelayCommand]
|
|
private void DeleteContract()
|
|
private void DeleteContract()
|
|
{
|
|
{
|
|
- if (_selecteContractDetail == null)
|
|
|
|
|
|
+ if (_selectedContractDetail == null)
|
|
{
|
|
{
|
|
MessageBox.Show("请先选中一行,再进行删除操作!");
|
|
MessageBox.Show("请先选中一行,再进行删除操作!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- ContractDetails.Remove(_selecteContractDetail);
|
|
|
|
|
|
+ ContractDetails.Remove(_selectedContractDetail);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -553,7 +532,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
[RelayCommand]
|
|
[RelayCommand]
|
|
private void ContractSelectionChanged(SelectContractDetailModel detail)
|
|
private void ContractSelectionChanged(SelectContractDetailModel detail)
|
|
{
|
|
{
|
|
- _selecteContractDetail = detail;
|
|
|
|
|
|
+ _selectedContractDetail = detail;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -628,53 +607,59 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
/// </summary>
|
|
/// </summary>
|
|
private bool SaveInspectAndDetails()
|
|
private bool SaveInspectAndDetails()
|
|
{
|
|
{
|
|
- _inspectApply = new InspectApply();
|
|
|
|
- _inspectApply.ApplyNo = _applyNo;
|
|
|
|
- _inspectApply.InspCategory = InspCategory;
|
|
|
|
- _inspectApply.ProductName = SelectedMaterial.Name;
|
|
|
|
- _inspectApply.MaterialGuid = SelectedMaterial.Guid;
|
|
|
|
- _inspectApply.CompanyGuid = SelectedCompany.Guid;
|
|
|
|
- _inspectApply.Company = SelectedCompany.Name;
|
|
|
|
- _inspectApply.InspQuantity = InspQuantity;
|
|
|
|
- _inspectApply.StartProductDate = StartProductDate;
|
|
|
|
- _inspectApply.EndProductDate = EndProductDate;
|
|
|
|
- _inspectApply.InspDate = InspDate;
|
|
|
|
- _inspectApply.BatchNo = BatchNo;
|
|
|
|
- _inspectApply.InspReportNo = InspReportNo;
|
|
|
|
- _inspectApply.ApplyDescription = ApplyDescription;
|
|
|
|
- _inspectApply.ReportStatus = false;
|
|
|
|
- _inspectApply.InspReport = InspReport; //检验报告附件
|
|
|
|
- _inspectApply.ApplyUser = App.CurrentUser!.UserName;
|
|
|
|
- _inspectApply.Year = WorkYear;
|
|
|
|
-
|
|
|
|
- _inspectApply.InspectApplyDetails = new ObservableCollection<InspectApplyDetail>();
|
|
|
|
|
|
+ _inspectApply = new InspectApply
|
|
|
|
+ {
|
|
|
|
+ ApplyNo = _applyNo,
|
|
|
|
+ InspCategory = InspCategory,
|
|
|
|
+ ProductName = SelectedMaterial?.Name ?? string.Empty,
|
|
|
|
+ MaterialGuid = SelectedMaterial?.Guid ?? Guid.Empty,
|
|
|
|
+ CompanyGuid = SelectedCompany?.Guid ?? Guid.Empty,
|
|
|
|
+ Company = SelectedCompany?.Name ?? string.Empty,
|
|
|
|
+ InspQuantity = InspQuantity,
|
|
|
|
+ StartProductDate = StartProductDate,
|
|
|
|
+ EndProductDate = EndProductDate,
|
|
|
|
+ InspDate = InspDate,
|
|
|
|
+ BatchNo = BatchNo,
|
|
|
|
+ InspReportNo = InspReportNo,
|
|
|
|
+ ApplyDescription = ApplyDescription,
|
|
|
|
+ ReportStatus = false,
|
|
|
|
+ InspReport = InspReport, //检验报告附件
|
|
|
|
+ ApplyUser = App.CurrentUser!.UserName,
|
|
|
|
+ Year = WorkYear,
|
|
|
|
+
|
|
|
|
+ InspectApplyDetails = []
|
|
|
|
+ };
|
|
foreach (var detail in InspectApplyDetails)
|
|
foreach (var detail in InspectApplyDetails)
|
|
{
|
|
{
|
|
- InspectApplyDetail newDetail = new InspectApplyDetail();
|
|
|
|
- newDetail.ApplyGuid = _inspectApply.Guid;
|
|
|
|
- newDetail.ApplyNo = _applyNo;
|
|
|
|
- newDetail.PacketNo = detail.PacketNo;
|
|
|
|
- newDetail.Quantity = detail.Quantity;
|
|
|
|
- newDetail.Note = detail.Note;
|
|
|
|
- newDetail.InspectApply = _inspectApply;
|
|
|
|
|
|
+ InspectApplyDetail newDetail = new()
|
|
|
|
+ {
|
|
|
|
+ ApplyGuid = _inspectApply.Guid,
|
|
|
|
+ ApplyNo = _applyNo,
|
|
|
|
+ PacketNo = detail.PacketNo,
|
|
|
|
+ Quantity = detail.Quantity,
|
|
|
|
+ Note = detail.Note,
|
|
|
|
+ InspectApply = _inspectApply
|
|
|
|
+ };
|
|
|
|
|
|
_inspectApply.InspectApplyDetails.Add(newDetail);
|
|
_inspectApply.InspectApplyDetails.Add(newDetail);
|
|
}
|
|
}
|
|
|
|
|
|
- _inspectApply.InspectApplyContractDetails = new ObservableCollection<InspectApplyContractDetail>();
|
|
|
|
|
|
+ _inspectApply.InspectApplyContractDetails = [];
|
|
|
|
|
|
foreach (var detail in ContractDetails)
|
|
foreach (var detail in ContractDetails)
|
|
{
|
|
{
|
|
- InspectApplyContractDetail newDetail = new InspectApplyContractDetail();
|
|
|
|
- newDetail.ApplyGuid = _inspectApply.Guid;
|
|
|
|
- newDetail.ApplyNo = _applyNo;
|
|
|
|
- newDetail.ContractDetailGuid = detail.Guid;
|
|
|
|
- newDetail.PurchaseCompany = detail.PurchaseCompany;
|
|
|
|
- newDetail.PurchaseCompanyShortName = detail.PurchaseCompanyShortName;
|
|
|
|
- newDetail.ContractNo = detail.ContractNo;
|
|
|
|
- newDetail.SigningDate = detail.SigningDate;
|
|
|
|
- newDetail.UnInspectQty = detail.UnInspectQty;
|
|
|
|
- newDetail.InspectQty = detail.ShareInspectQty;
|
|
|
|
|
|
+ InspectApplyContractDetail newDetail = new()
|
|
|
|
+ {
|
|
|
|
+ ApplyGuid = _inspectApply.Guid,
|
|
|
|
+ ApplyNo = _applyNo,
|
|
|
|
+ ContractDetailGuid = detail.Guid,
|
|
|
|
+ PurchaseCompany = detail.PurchaseCompany,
|
|
|
|
+ PurchaseCompanyShortName = detail.PurchaseCompanyShortName,
|
|
|
|
+ ContractNo = detail.ContractNo,
|
|
|
|
+ SigningDate = detail.SigningDate,
|
|
|
|
+ UnInspectQty = detail.UnInspectQty,
|
|
|
|
+ InspectQty = detail.ShareInspectQty
|
|
|
|
+ };
|
|
|
|
|
|
_inspectApply.InspectApplyContractDetails.Add(newDetail);
|
|
_inspectApply.InspectApplyContractDetails.Add(newDetail);
|
|
}
|
|
}
|
|
@@ -703,23 +688,19 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
{
|
|
{
|
|
//扣减剩余数量
|
|
//扣减剩余数量
|
|
detail.ShareInspectQty = remainQty;
|
|
detail.ShareInspectQty = remainQty;
|
|
- remainQty = 0;
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //没有扣减完成,则找到第一个合同单据完成剩余扣减
|
|
|
|
- //if (remainQty > 0)
|
|
|
|
- //{
|
|
|
|
- // contractDetails[0].ShareInspectQty += remainQty;
|
|
|
|
- //}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 更新合同明细中报检状态、已报检数量
|
|
/// 更新合同明细中报检状态、已报检数量
|
|
/// </summary>
|
|
/// </summary>
|
|
- private bool UpdateContractDetail()
|
|
|
|
|
|
+ private void UpdateContractDetail()
|
|
{
|
|
{
|
|
- var contractDetailList = _contractDetailService.GetAll(x => x.Contract.CompanyGuid == SelectedCompany.Guid && x.Material.Name == SelectedMaterial.Name).ToList();
|
|
|
|
|
|
+ var materialName = SelectedMaterial?.Name ?? string.Empty;
|
|
|
|
+ var companyGuid = SelectedCompany?.Guid ?? Guid.Empty;
|
|
|
|
+ var contractDetailList = _contractDetailService.GetAll(x => x.Contract.CompanyGuid == companyGuid && x.Material.Name == materialName).ToList();
|
|
|
|
|
|
//更新已报检数量
|
|
//更新已报检数量
|
|
foreach (var detail in ContractDetails)
|
|
foreach (var detail in ContractDetails)
|
|
@@ -752,7 +733,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return _contractDetailService.SaveChanges();
|
|
|
|
|
|
+ _contractDetailService.SaveChanges();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -770,7 +751,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
|
|
|
TotalPackage = InspectApplyDetails.Count;
|
|
TotalPackage = InspectApplyDetails.Count;
|
|
|
|
|
|
- string result = InspectApplyUtil.ReplaceApplyDescription(ApplyDescription, "InspQuantity", $"[{InspQuantity}{SelectedMaterial?.MeasureUnit}]");
|
|
|
|
|
|
+ var result = InspectApplyUtil.ReplaceApplyDescription(ApplyDescription ?? string.Empty, "InspQuantity", $"[{InspQuantity}{SelectedMaterial?.MeasureUnit}]");
|
|
ApplyDescription = InspectApplyUtil.ReplaceApplyDescription(result, "PackageQty", $"[{TotalPackage}]");
|
|
ApplyDescription = InspectApplyUtil.ReplaceApplyDescription(result, "PackageQty", $"[{TotalPackage}]");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -780,7 +761,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
private void GenerateSerialNumber()
|
|
private void GenerateSerialNumber()
|
|
{
|
|
{
|
|
var companyGuid = SelectedCompany!.Guid;
|
|
var companyGuid = SelectedCompany!.Guid;
|
|
- var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
|
|
|
|
|
|
+ var supervisionUnitGuid = App.CurrentUser!.SupervisionUnit.Guid;
|
|
|
|
|
|
var serials = _serialService.Query(s =>
|
|
var serials = _serialService.Query(s =>
|
|
s.CompanyGuid == companyGuid
|
|
s.CompanyGuid == companyGuid
|
|
@@ -808,7 +789,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
private void UpdateSerialNumber()
|
|
private void UpdateSerialNumber()
|
|
{
|
|
{
|
|
var companyGuid = SelectedCompany!.Guid;
|
|
var companyGuid = SelectedCompany!.Guid;
|
|
- var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
|
|
|
|
|
|
+ var supervisionUnitGuid = App.CurrentUser!.SupervisionUnit.Guid;
|
|
|
|
|
|
var serials = _serialService.GetAll(s =>
|
|
var serials = _serialService.GetAll(s =>
|
|
s.CompanyGuid == companyGuid
|
|
s.CompanyGuid == companyGuid
|
|
@@ -821,10 +802,9 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
if (serials.Count > 0)
|
|
if (serials.Count > 0)
|
|
{
|
|
{
|
|
var serial = serials[0];
|
|
var serial = serials[0];
|
|
- int newMax;
|
|
|
|
int oldMax = int.Parse(serial.MaxNumber);
|
|
int oldMax = int.Parse(serial.MaxNumber);
|
|
|
|
|
|
- if (SerialNumber.Length > 3 || !int.TryParse(SerialNumber, out newMax)) return;
|
|
|
|
|
|
+ if (SerialNumber.Length > 3 || !int.TryParse(SerialNumber, out int newMax)) return;
|
|
if (newMax > oldMax)
|
|
if (newMax > oldMax)
|
|
{
|
|
{
|
|
serial.MaxNumber = newMax.ToString("000");
|
|
serial.MaxNumber = newMax.ToString("000");
|
|
@@ -835,7 +815,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
var newSerialNumber = new SerialNumber()
|
|
var newSerialNumber = new SerialNumber()
|
|
{
|
|
{
|
|
CompanyGuid = SelectedCompany!.Guid,
|
|
CompanyGuid = SelectedCompany!.Guid,
|
|
- CompanyCode = CompanyCode,
|
|
|
|
|
|
+ CompanyCode = CompanyCode ?? string.Empty,
|
|
SupervisionUnitGuid = App.CurrentUser.SupervisionUnit.Guid,
|
|
SupervisionUnitGuid = App.CurrentUser.SupervisionUnit.Guid,
|
|
InspCategory = InspCategory,
|
|
InspCategory = InspCategory,
|
|
Year = WorkYear,
|
|
Year = WorkYear,
|
|
@@ -847,40 +827,6 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
_serialService.SaveChanges();
|
|
_serialService.SaveChanges();
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 校验用户输入的流水号不能超过系统记录的最大流水号
|
|
|
|
- /// </summary>
|
|
|
|
- private bool CheckCustomSerialNumber(string serialNumber)
|
|
|
|
- {
|
|
|
|
- var companyGuid = SelectedCompany!.Guid;
|
|
|
|
- var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
|
|
|
|
-
|
|
|
|
- var serials = _serialService.Query(s =>
|
|
|
|
- s.CompanyGuid == companyGuid
|
|
|
|
- && s.CompanyCode == CompanyCode
|
|
|
|
- && s.SupervisionUnitGuid == supervisionUnitGuid
|
|
|
|
- && s.InspCategory == InspCategory
|
|
|
|
- && s.Year == WorkYear
|
|
|
|
- ).ToList();
|
|
|
|
-
|
|
|
|
- if (serials.Count == 0)
|
|
|
|
- {
|
|
|
|
- MessageBox.Show("不存在断号的流水号,请自动生成流水号!");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- string maxNumber = serials.FirstOrDefault().MaxNumber;
|
|
|
|
- if (int.Parse(serialNumber) > (int.Parse(maxNumber)))
|
|
|
|
- {
|
|
|
|
- MessageBox.Show("手动录入编号时,只允许录入断号流水号!您输入的流水号已超出目前最大流水号,请选择自动获取编号或者使用断号流水号!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|