PDAService.cs
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using ApkInfo;
using Hh.Mes.Common;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.Common.Redis;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel;
using Hh.Mes.Service.Repository;
using Hh.Mes.Service.SystemAuth;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Hh.Mes.Service
{
public class PDAService : RepositorySqlSugar<sys_user>
{
AuthContextFactory authContextFactory;
public PDAService(AuthContextFactory authContextFactory)
{
this.authContextFactory = authContextFactory;
}
/// <summary>
/// PDA物料追溯查询
/// (扫码查询物料追溯码,查看物料的批次,物料名称,壁厚等物料信息)
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
public dynamic GetMaterialInfoByBarCode(string barCode)
{
return ExceptionsHelp.Instance.ExecuteT<dynamic>(() =>
{
var response = new Response();
//1:扫码 BarCode 查询bus_workOrder_detail 表确认BarCode是否存在。
var bwdInfo = Context.Queryable<bus_workOrder_detail>().First(x => x.BarCode == barCode);
if (bwdInfo == null || string.IsNullOrEmpty(bwdInfo.BarCode))
{
response.Code = 500;
response.Message = $"BarCode:【{barCode}】不存在工序任务明细表中,请核对!";
return response;
}
if (string.IsNullOrEmpty(bwdInfo.materialCode))
{
response.Code = 500;
response.Message = $"根据BarCode:【{barCode}】未查询到工序任务明细表中的物料编码信息,请核对!";
return response;
}
//2:根据BarCode 查询到当前行的 materialCode,在去物料表查询 返回物料表的基础信息。
var materialInfo = Context.Queryable<base_material>().First(x => x.materialCode == bwdInfo.materialCode);
if (materialInfo == null)
{
response.Code = 500;
response.Message = $"未查询到{bwdInfo.materialCode}的物料基础信息,请检查!";
return response;
}
response.Code = 200;
response.Result = materialInfo;
return response;
});
}
}
}