Tjiny
2025-05-23 cd195e83605f60ac51db6e0b4f0fcaeeb200768d
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
using System;
using System.Linq;
using HH.WCS.Mobox3.Template.Entity;
using HH.WCS.Mobox3.Template.Entity.Dto;
using HH.WCS.Mobox3.Template.Util.Helper;
 
namespace HH.WCS.Mobox3.Template.Controller.Service
{
    /// <summary>
    /// 作业实现类
    /// </summary>
    public static class OperationService
    {
        /// <summary>
        /// 推送作业
        /// </summary>
        /// <param name="operationCode">任务号</param>
        /// <returns></returns>
        public static ResultDto<object> SendOperation(string operationCode)
        {
            var result = new ResultDto<object>();
            
            // 查询该托盘作业是否存在
            var operation = AdoSqlHelper<Operation>.QueryFirst(p=>p.S_CODE == operationCode);
 
            // 任务不存在
            if (operation == null)
            {
                // 任务不存在
                result.code = 400;
                result.msg = "当前任务不存在";
                return result;
            }
            
            // 任务存在,下发任务给线体到指定终点
            var conveyorlinesInfoDto = Settings.ConveyorlinesInfos.First(p=>p.purpose == "入库口");
            
            // 给入库口写条形码以及目的地,任务号等数据
            // S7....
            
            // 修改任务状态
            operation.N_B_STATE = 1;
            operation.S_B_STATE = "执行中";
            operation.T_START_TIME = DateTime.Now;
            AdoSqlHelper<Operation>.UpdateFirst(operation, p => new { p.N_B_STATE, p.S_B_STATE, p.T_START_TIME });
            
            result.code = 200;
            result.msg = "任务推送成功";
            return result;
        }
    }
}