Admin
6 天以前 bd6818fc9d40f343547bafca0743658f3c0379dc
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WIDESEA.Common;
using WIDESEA.Core.Enums;
using WIDESEA.Core.ManageUser;
using WIDESEA.Core.Services;
using WIDESEA.Core.Utilities;
using WIDESEA.Entity.DomainModels;
using WIDESEA.Services.IServices.ToApp;
using WIDESEA.Services.Repositories;
using WIDESEA.Services.Services;
using WIDESEA_Entity.DomainModels;
 
 
namespace WIDESEA_Services.Services
{
    public partial class ToAPPOperation
    {
        /// <summary>
        /// 测量复核
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public WebResponseContent MeasureCheckAction(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
 
                string containerdtl_id = saveModel.MainData["containerdtl_id"]?.ToString();
                string checkResult = saveModel.MainData["checkResult"]?.ToString();
                VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.Instance.FindFirst(r => Guid.Parse(containerdtl_id) == r.containerdtl_id);
                if (null == containerInfo)
                    return content.Error("获取库存信息失败.");
 
                Dt_taskinfo task = Dt_taskinfoRepository.Instance.FindFirst(r => r.task_barcode == containerInfo.containerdtl_barcode);
                if (null == task)
                    return content.Error("未找到测量复核出库的任务.");
 
                dt_checkRecord record = dt_checkRecordRepository.Instance.Find(r => r.record_materielNumber == containerInfo.containerdtl_number)
                    .OrderByDescending(r => r.record_createTime).FirstOrDefault();
                if (null == record)
                    return content.Error("未找到抽检记录");
 
                if (string.IsNullOrEmpty(checkResult))
                    return content.Error("请选择抽检结果.");
 
                content = Dt_taskinfoRepository.Instance.DbContextBeginTransaction(() =>
                 {
 
                     record.record_result = checkResult;
                     dt_checkRecordRepository.Instance.Update(record, x => x.record_result, true);
                     task.task_state = TaskState.TaskState_Finished.ToString();
                     CommonFunction.AddWMSTaskToHistory(task);
 
                     Dt_taskinfo taskinfo = new Dt_taskinfo();
                     taskinfo.task_id = Guid.NewGuid();
                     taskinfo.task_type = "合格".Equals(checkResult) ? TaskType.TaskType_CheckBackIn.ToString() : TaskType.TaskType_ErrorCheckBackIn.ToString();
                     taskinfo.task_state = TaskState.TaskState_Create.ToString();
                     taskinfo.task_barcode = containerInfo.containerdtl_barcode;
                     taskinfo.task_materielid = containerInfo.materiel_id;
                     //起始货位,就是目的站台
                     taskinfo.task_fromlocationid = LayerToStation.OutLayerToStation(containerInfo.location_layer);
                     //目的货位
                     taskinfo.task_tolocationid = containerInfo.location_id;
                     //起始站台
                     taskinfo.task_beginstation = "20101";
                     //目的站台
                     taskinfo.task_endstation = LayerToStation.OutLayerToStation(containerInfo.location_layer);
                     taskinfo.task_grade = 0;
                     taskinfo.task_isunpacked = false;
                     taskinfo.task_creator = UserContext.Current.UserTrueName;
                     taskinfo.task_createtime = DateTime.Now;
                     taskinfo.task_weight = containerInfo.containerdtl_goodsWeight;
                     taskinfo.task_materielType = containerInfo.containerdtl_type;
                     taskinfo.task_sn = containerInfo.containerdtl_number;
                     Dt_taskinfoRepository.Instance.Add(taskinfo, true);
 
                     content = WCSApi.SendTaskToWCS(new List<Dt_taskinfo>() { taskinfo });
                     if (content.Status)
                         content.OK($"测量复核回库任务下发给WCS成功.");
                     else
                         content.Error($"测量复核回库任务下发给WCS失败,原因 => {content.Message}");
 
                     return content;
                 });
            }
            catch (Exception ex)
            {
                content.Error("测量复核确认失败:" + ex.Message);
            }
            Logger.AddLog(LoggerType.Add, saveModel, content, content);
            return content;
        }
    }
}