1
This commit is contained in:
253
Gatedge.ScanCode/Services/BarRecordService.cs
Normal file
253
Gatedge.ScanCode/Services/BarRecordService.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
using Gatedge.K3Cloud.Utils;
|
||||
using Gatedge.K3Cloud.Utils.Common;
|
||||
using Gatedge.K3Cloud.Utils.Model.K3Request;
|
||||
using Gatedge.K3Cloud.Utils.Model.K3Result;
|
||||
using Gatedge.K3Cloud.Utils.Model.K3Result.Model;
|
||||
using Gatedge.ScanCode.Models.Dto.BarRecord;
|
||||
using Gatedge.ScanCode.Models.K3Request.Auxprop;
|
||||
using Gatedge.ScanCode.Models.K3Request.BaseData;
|
||||
using Gatedge.ScanCode.Models.K3Request.Enum;
|
||||
using Gatedge.ScanCode.Models.K3Request.SaveModel;
|
||||
using Gatedge.ScanCode.Models.Vo;
|
||||
using Gatedge.ScanCode.Services.IServices;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Gatedge.ScanCode.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 条码扫描记录服务类
|
||||
/// </summary>
|
||||
public class BarRecordService : IBarRecordService
|
||||
{
|
||||
/// <summary>
|
||||
/// 单据FormId
|
||||
/// </summary>
|
||||
private readonly string _FormId = "ke3a69108a53e4baba04b1bf338355b6a";
|
||||
|
||||
/// <summary>
|
||||
/// 金蝶云星空工具类
|
||||
/// </summary>
|
||||
private readonly K3CloudApiUtils _utils;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化工具类
|
||||
/// </summary>
|
||||
/// <param name="utils"></param>
|
||||
public BarRecordService(K3CloudApiUtils utils)
|
||||
{
|
||||
_utils = utils;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 审核接口
|
||||
/// </summary>
|
||||
/// <param name="auditParam"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus Audit(Audit auditParam)
|
||||
{
|
||||
return _utils.Audit(this._FormId, auditParam);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 撤销接口
|
||||
/// </summary>
|
||||
/// <param name="cancelAssignBarRecord"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus CancelAssign(CancelAssign cancelAssignBarRecord)
|
||||
{
|
||||
return _utils.CancelAssign(this._FormId, cancelAssignBarRecord);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据条码查找条码扫描记录
|
||||
/// </summary>
|
||||
/// <param name="barCode"></param>
|
||||
/// <returns></returns>
|
||||
public ListResult FindIdByCode(string barCode)
|
||||
{
|
||||
Query queryParam = new Query()
|
||||
{
|
||||
FormId = this._FormId,
|
||||
FieldKeys = "FID,FBillNo,FDocumentStatus,FOrgId.FNumber,FCreatorId,FCreatorId.FName,FCreateDate,FBarCode,FErrorInfo",
|
||||
Limit = 2000,
|
||||
StartRow = 0,
|
||||
};
|
||||
FilterList filterString = new FilterList();
|
||||
FilterItem filterItem = new FilterItem("FBarCode", "67", barCode, "0");
|
||||
filterString.AddFilterItem(filterItem);
|
||||
queryParam.FilterString = filterString.GetFilterString();
|
||||
return List(queryParam);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查看列表接口
|
||||
/// </summary>
|
||||
/// <param name="queryParam"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public ListResult List(Query queryParam)
|
||||
{
|
||||
queryParam.FormId = this._FormId;
|
||||
var result = _utils.QueryList(queryParam);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印条码接口
|
||||
/// </summary>
|
||||
/// <param name="barRecord"></param>
|
||||
/// <returns></returns>
|
||||
public void PrintResultBillNo(BarRecord barRecord)
|
||||
{
|
||||
|
||||
Save<BarRecordSave> saveParam = new Save<BarRecordSave>()
|
||||
{
|
||||
IsDeleteEntry = false,
|
||||
Model = new BarRecordSave()
|
||||
{
|
||||
FID = barRecord.BarRecordId,
|
||||
FIsPrinted = "1"
|
||||
}
|
||||
};
|
||||
this.Save(saveParam);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存条码扫描记录
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus Save(List<BarRecordsSaveDto> param)
|
||||
{
|
||||
BarRecordSave barRecordSeve = new BarRecordSave()
|
||||
{
|
||||
FStatus = BarRecordStatus.Draft,
|
||||
FIsPrinted = "0",
|
||||
FErrorInfo = string.Empty,
|
||||
FBarEntity = param.Select(n => new BarRecordSave.BarEntry()
|
||||
{
|
||||
FBarBillId = new FormType()
|
||||
{
|
||||
FID = n.FBarBillId
|
||||
},
|
||||
FBarBillNo = n.FBarBillNo,
|
||||
FBarSeq = n.FBarSeq,
|
||||
FBarCode = n.FBarCode,
|
||||
FBarMaterialId = n.FBarMaterialId == 0 ? null : new Material()
|
||||
{
|
||||
FMaterialId = n.FBarMaterialId,
|
||||
},
|
||||
FBarStockId = n.FBarStockId == 0 ? null : new Stock()
|
||||
{
|
||||
FStockId = n.FBarStockId,
|
||||
},
|
||||
FBarQty = n.FBarQty,
|
||||
FBarMoEntryId = n.FMoEntryId == 0 ? null : new MoEntry()
|
||||
{
|
||||
FEntryId = n.FMoEntryId
|
||||
},
|
||||
FBarAuxPropId = n.FBarAuxpropId == 0 ? null : n.FBarAuxpropId
|
||||
|
||||
}),
|
||||
};
|
||||
var billSave = new Save<BarRecordSave>();
|
||||
billSave.Model = barRecordSeve;
|
||||
var result = Save(billSave);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标准保存接口
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus Save(Save<BarRecordSave> param)
|
||||
{
|
||||
var result = _utils.Save(_FormId, param);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存错误信息
|
||||
/// </summary>
|
||||
/// <param name="barRecordId"></param>
|
||||
/// <param name="ErrorInfo"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus SaveErrorInfo(int barRecordId, string ErrorInfo)
|
||||
{
|
||||
Save<BarRecordSave> barRecordSave = new Save<BarRecordSave>()
|
||||
{
|
||||
IsAutoSubmitAndAudit = false,
|
||||
IsDeleteEntry = false,
|
||||
Model = new BarRecordSave()
|
||||
{
|
||||
FID = barRecordId,
|
||||
FStatus = BarRecordStatus.Error,
|
||||
FErrorInfo = ErrorInfo
|
||||
}
|
||||
};
|
||||
return this.Save(barRecordSave);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交扫描记录
|
||||
/// </summary>
|
||||
/// <param name="submitBarRecor"></param>
|
||||
/// <returns></returns>
|
||||
public K3CloudResponseStatus Submit(Submit submitBarRecor)
|
||||
{
|
||||
return _utils.Submit(_FormId, submitBarRecor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交成功信息
|
||||
/// </summary>
|
||||
/// <param name="barRecordId"></param>
|
||||
/// <param name="resultEntityList"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public K3CloudResponseStatus SubmitSuccess(int barRecordId, IEnumerable<BarRecordSave.ResultEntry> resultEntityList)
|
||||
{
|
||||
Save<BarRecordSave> barRecordSave = new Save<BarRecordSave>()
|
||||
{
|
||||
IsAutoSubmitAndAudit = false,
|
||||
IsDeleteEntry = false,
|
||||
Model = new BarRecordSave()
|
||||
{
|
||||
FID = barRecordId,
|
||||
FStatus = BarRecordStatus.Success,
|
||||
FErrorInfo = string.Empty,
|
||||
FResultEntity = resultEntityList
|
||||
|
||||
}
|
||||
};
|
||||
this.Save(barRecordSave);
|
||||
// 此时已经提交单据
|
||||
this.Submit(new Submit()
|
||||
{
|
||||
Ids = barRecordId.ToString()
|
||||
});
|
||||
|
||||
return this.Audit(new Audit()
|
||||
{
|
||||
Ids = barRecordId.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查看单据接口
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public BarRecordVo View(View param)
|
||||
{
|
||||
return _utils.Query<BarRecordVo>(_FormId, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user