241 lines
7.8 KiB
C#
241 lines
7.8 KiB
C#
|
|
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;
|
|||
|
|
using Gatedge.ScanCode.Models.Dto.BarRecord;
|
|||
|
|
using Gatedge.ScanCode.Models.Dto.ScanRecords;
|
|||
|
|
using Gatedge.ScanCode.Models.K3Request.BaseData;
|
|||
|
|
using Gatedge.ScanCode.Models.K3Request.Enum;
|
|||
|
|
using Gatedge.ScanCode.Models.K3Request.SaveModel;
|
|||
|
|
using Gatedge.ScanCode.Services.IServices;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Text.Json;
|
|||
|
|
|
|||
|
|
namespace Gatedge.ScanCode.Services
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 暂存扫描记录
|
|||
|
|
/// </summary>
|
|||
|
|
public class ScanRecordsService : IScanRecordsService
|
|||
|
|
{
|
|||
|
|
private readonly string _FormName = "扫描记录#";
|
|||
|
|
private readonly string _FormId = "k4b27f8773ecb443da113e1a5e64ccaf9";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 金蝶云星空工具类
|
|||
|
|
/// </summary>
|
|||
|
|
private readonly K3CloudApiUtils _utils;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 初始化工具类
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="utils"></param>
|
|||
|
|
public ScanRecordsService(K3CloudApiUtils utils)
|
|||
|
|
{
|
|||
|
|
_utils = utils;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除接口
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="deleteParam"></param>
|
|||
|
|
public K3CloudResponseStatus Delete(Delete deleteParam)
|
|||
|
|
{
|
|||
|
|
var result = _utils.Delete(_FormId, deleteParam);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 列表
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ListResult List(Query queryParam)
|
|||
|
|
{
|
|||
|
|
var result = _utils.QueryList(queryParam);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存暂存记录
|
|||
|
|
/// </summary>
|
|||
|
|
public K3CloudResponseStatus Save(ScanRecordsSaveDto param)
|
|||
|
|
{
|
|||
|
|
ScanRecordsSave saveModel = new ScanRecordsSave()
|
|||
|
|
{
|
|||
|
|
FBillNo = param.FBillNo,
|
|||
|
|
FBarCode = param.FBarCode,
|
|||
|
|
FQty = param.FQty,
|
|||
|
|
Flot = param.Flot,
|
|||
|
|
FEntryId = param.FEntryId,
|
|||
|
|
FSubmitLot = param.FSubmitLot,
|
|||
|
|
FJSON = param.FJSON,
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
if (param.FBillId != null)
|
|||
|
|
{
|
|||
|
|
saveModel.FBillId = new FormType()
|
|||
|
|
{
|
|||
|
|
FID = param.FBillId
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
if (param.FMaterialId != null)
|
|||
|
|
{
|
|||
|
|
saveModel.FMaterialId = new Material()
|
|||
|
|
{
|
|||
|
|
FMaterialId = Convert.ToInt32(param.FMaterialId)
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
if (param.FStockId != null)
|
|||
|
|
{
|
|||
|
|
saveModel.FStockId = new Stock()
|
|||
|
|
{
|
|||
|
|
FStockId = Convert.ToInt32(param.FStockId)
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
var billSave = new Save<ScanRecordsSave>();
|
|||
|
|
billSave.Model = saveModel;
|
|||
|
|
var result = _utils.Save(_FormId, billSave);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="param"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public K3CloudResponseStatus PatchSave(ArrayDto<ScanRecordsSaveDto> param)
|
|||
|
|
{
|
|||
|
|
var saveList = param.Data.Select(n => new ScanRecordsSave()
|
|||
|
|
{
|
|||
|
|
FBillNo = n.FBillNo,
|
|||
|
|
FBarCode = n.FBarCode,
|
|||
|
|
FQty = n.FQty,
|
|||
|
|
Flot = n.Flot,
|
|||
|
|
FEntryId = n.FEntryId,
|
|||
|
|
FJSON = n.FJSON,
|
|||
|
|
FSubmitLot = n.FSubmitLot,
|
|||
|
|
FBillId = new FormType()
|
|||
|
|
{
|
|||
|
|
FID = n.FBillId
|
|||
|
|
},
|
|||
|
|
FMaterialId = new Material()
|
|||
|
|
{
|
|||
|
|
FMaterialId = Convert.ToInt32(n.FMaterialId)
|
|||
|
|
},
|
|||
|
|
FStockId = new Stock()
|
|||
|
|
{
|
|||
|
|
FStockId = Convert.ToInt32(n.FStockId)
|
|||
|
|
}
|
|||
|
|
}).ToList();
|
|||
|
|
var billSave = new PatchSave<ScanRecordsSave>();
|
|||
|
|
billSave.Model = saveList;
|
|||
|
|
var result = _utils.BatchSave(_FormId, billSave);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查看
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="param"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public object View(View param)
|
|||
|
|
{
|
|||
|
|
return _utils.Query(_FormId, param);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 提交成功信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ids">扫描记录Id,通过','连接</param>
|
|||
|
|
/// <param name="resultBillId"></param>
|
|||
|
|
/// <param name="response"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public K3CloudResponseStatus SubmitSuccess(string ids, string resultBillId, K3CloudResponseStatus response)
|
|||
|
|
{
|
|||
|
|
var saveList = ids.Split(',').Select(n => new ScanRecordsSave()
|
|||
|
|
{
|
|||
|
|
FID = n,
|
|||
|
|
FStatus = BarRecordStatus.Success,
|
|||
|
|
FErrorInfo = string.Empty,
|
|||
|
|
FResultInfo = JsonSerializer.Serialize(response),
|
|||
|
|
FResultBillNo = response.SuccessEntitys.First().Number,
|
|||
|
|
FResultId = response.SuccessEntitys.First().Id.ToString(),
|
|||
|
|
FResultBillId = new FormType
|
|||
|
|
{
|
|||
|
|
FID = resultBillId,
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
var billSave = new PatchSave<ScanRecordsSave>()
|
|||
|
|
{
|
|||
|
|
Model = saveList
|
|||
|
|
};
|
|||
|
|
var result = _utils.BatchSave(_FormId, billSave);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 提交失败,更新状态和错误信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <param name="errorInfo"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public K3CloudResponseStatus SubmitError(string id, string errorInfo)
|
|||
|
|
{
|
|||
|
|
var saveParam = new Save<ScanRecordsSave>()
|
|||
|
|
{
|
|||
|
|
Model = new ScanRecordsSave()
|
|||
|
|
{
|
|||
|
|
FID = id,
|
|||
|
|
FStatus = BarRecordStatus.Error,
|
|||
|
|
FErrorInfo = errorInfo,
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return _utils.Save(_FormId, saveParam);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据条码查找扫描记录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="barCode"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ListResult FindIdByCode(string barCode)
|
|||
|
|
{
|
|||
|
|
Query queryParam = new Query()
|
|||
|
|
{
|
|||
|
|
FormId = this._FormId,
|
|||
|
|
FieldKeys = "FID,FStatus,FBillId.FID,FBillId.FName,FBillNo,FCreatorId,FCreatorId.FName,FCreateDate,FBarCode,FEntryId,FMaterialId,FMaterialId.FNumber,FMaterialId.FName,FQty,FStockId,FStockId.FNumber,FStockId.FName,Flot,FJSON,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="ids"></param>
|
|||
|
|
public K3CloudResponseStatus PrintResultBillNo(List<string> ids)
|
|||
|
|
{
|
|||
|
|
var patchSave = new PatchSave<ScanRecordsSave>();
|
|||
|
|
var scanRecordsSaves = ids.Distinct().Select(n => new ScanRecordsSave()
|
|||
|
|
{
|
|||
|
|
FID = n,
|
|||
|
|
FIsPrinted = true,
|
|||
|
|
}).ToList();
|
|||
|
|
patchSave.Model = scanRecordsSaves;
|
|||
|
|
return _utils.BatchSave(_FormId, patchSave);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|