89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using HHWMS.Web.Models;
|
|
using ICSharpCode.SharpZipLib.Core;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using WalkingTec.Mvvm.Core;
|
|
using WalkingTec.Mvvm.Core.Extensions;
|
|
using WalkingTec.Mvvm.Mvc;
|
|
|
|
namespace HHWMS.Web.Controllers
|
|
{
|
|
[Area("configs")]
|
|
[ActionDescription("打印管理")]
|
|
public partial class PrintController : BaseController
|
|
{
|
|
private readonly IUnitWork _unitwork;
|
|
|
|
public PrintController(IUnitWork unitwork)
|
|
{
|
|
_unitwork = unitwork;
|
|
}
|
|
|
|
#region Search
|
|
|
|
[ActionDescription("Sys.Search")]
|
|
public ActionResult Index()
|
|
{
|
|
var inv = _unitwork.Find<Inventory>(x => x.TaskStatus != InventoryTaskStatus.任务中)
|
|
.ToList()
|
|
.GroupBy(x => x.ContainerCode);
|
|
var vm = Wtm.CreateVM<ContainerListVM>();
|
|
return PartialView(vm);
|
|
}
|
|
#endregion Search
|
|
|
|
[HttpPost]
|
|
public ActionResult ScanCode(string code)
|
|
{
|
|
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(code));
|
|
if (material == null)
|
|
{
|
|
return JsonMore(null, 500, $"二维码{code}不存在!");
|
|
}
|
|
else
|
|
{
|
|
return JsonMore(null);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult GenCode(string code, int num = 1)
|
|
{
|
|
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(code));
|
|
if (material == null)
|
|
{
|
|
return JsonMore(null, 500, $"二维码{code}不存在!");
|
|
}
|
|
else
|
|
{
|
|
var materialQrList = new List<MaterialQr>();
|
|
var printList = new List<dynamic>();
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
var prefix = code.Split("@")[1].Substring(2);
|
|
var uniqueCode = _unitwork.GetSerialNumber(prefix, length: 8);
|
|
//var uniqueCode = prefix + unique;
|
|
|
|
materialQrList.Add(new MaterialQr
|
|
{
|
|
QRCode = code,
|
|
UniqueCode = uniqueCode,
|
|
CreateTime = DateTime.Now,
|
|
CreateBy = Wtm.LoginUserInfo.ITCode
|
|
});
|
|
printList.Add(new
|
|
{
|
|
UniqueCode = uniqueCode,
|
|
Batch = material.Batch
|
|
});
|
|
}
|
|
_unitwork.BatchAdd(materialQrList.ToArray());
|
|
return JsonMore(printList);
|
|
}
|
|
}
|
|
}
|
|
}
|