分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-06-07 fdf6494705b9bcddb2e16b933b231262497fc227
添加取消出库外协功能,设置模式1和模式2
已修改15个文件
已添加1个文件
324 ■■■■ 文件已修改
代码管理/PCS/WCS_Client/config/buttons.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Client/src/extension/widesea_wcs/wcs/dt_pattern.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/SendFromaddress.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/SendToaddress.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/GetStation/EmptyPalletStation.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/GetStation/EmptyTrayIn.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/OutboundTask.cs 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/PCS/WCS_Client/config/buttons.js
@@ -98,6 +98,15 @@
    onClick: function () {
        // this.FinishWorkOrder();
    }
}, {
    name: "取消",
    icon: 'el-icon-delete',
    type: 'danger',
    plain: true,
    value: 'CancelBtn',
    onClick: function () {
        // this.FinishWorkOrder();
    }
}
    // , {
    //     name: "数据结构",
´úÂë¹ÜÀí/PCS/WCS_Client/src/extension/widesea_wcs/tomes/dt_mes_head.js
@@ -32,14 +32,43 @@
        //       this.$Message.success('点击了按钮');
        //     }
        //   });
        // this.buttons.forEach(x => {
        //   if(x.value == 'FinishWorkOrder')
        //   {
        //     x.name = '完成工单'
        //     x.type='success'
        //     x.icon= 'el-icon-check'
        //   }
        // });
        this.buttons.forEach(x => {
          if(x.value == 'CancelBtn')
          {
            x.name = '取消出库外协'
          }
        });
        let CancelBtn = this.buttons.find(r => r.name == "取消出库外协");
        if(null!=CancelBtn){
          CancelBtn.onClick = function (){
            let rows = this.$refs.table.getSelected();
            if (rows.length == 0) return this.$error("请选择工单!");
            let addkeys = rows.map(x => {
                return x[this.table.key];
            });
            if (!addkeys || addkeys.Length == 0) return this.$error("未获取到工单!");
            this.$confirm("是否确认取消出库外协?","提示",{
                        // iconClass:"el-icon-success",//el-icon-remove自定义图标样式
                        confirmButtonText:"确认",//确认按钮文字更换
                        cancelButtonText:"取消",//取消按钮文字更换
                        // cancelBtn:"取消",//取消按钮文字更换
                        showClose: true,//是否显示右上角关闭按钮
                        type: "warning",//提示类型 success:成功/info:信息/warning:警告/error:报错
            }).then(()=>{
              let params = {
                MainData: null,
                DetailData: null,
                DelKeys: addkeys
            }
            this.http.post("/api/dt_mes_head/CancelsorcingWorkOrder", params, "正在处理工单....").then(x => {
                if (!x.status) return this.$error(x.message);
                this.$success("处理工单成功!");
                this.refresh();
            });
            })
          }
        }
        let OutsorcingBtn = this.buttons.find(r => r.name == "出库外协");
        if(null!=OutsorcingBtn){
          OutsorcingBtn.onClick = function (){
´úÂë¹ÜÀí/PCS/WCS_Client/src/extension/widesea_wcs/wcs/dt_pattern.js
@@ -59,7 +59,7 @@
                    // this.request(row);
                  }
                },
                '自动'
                '模式1'
              ),
              h(
                'span',
@@ -78,7 +78,7 @@
                    // this.request(row);
                  }
                },
                '手动'
                '模式2'
              )
            ]);
          }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/IServices/ToMES/Partial/Idt_mes_headService.cs
@@ -9,6 +9,8 @@
{
    public partial interface Idt_mes_headService
    {
        WebResponseContent CancelsorcingWorkOrder(SaveModel saveModel);
        /// <summary>
        /// æ‰‹åŠ¨å®Œæˆå·¥å•
        /// </summary>
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs
@@ -31,7 +31,6 @@
        private void DoAction(IJobExecutionContext context)
        {
            StationTask.CreateTask();//入库
            OutboundTask.CreateOutboundTask();//出库
            RestockHCJ.HCJGetBarcode();//更新队列
            EmptyTrayTask.CreateEmptyTrayTask();//创建补空托
            AutoUpdateWork.FinishMesWork();//处理工单
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Services/ToMES/Partial/dt_mes_headService.cs
@@ -21,6 +21,7 @@
using WIDESEA_WCS.JobsPart.Common;
using WIDESEA_Core.ManageUser;
using WIDESEA_Comm.LogInfo;
using System.Collections.Generic;
namespace WIDESEA_WCS.Services
{
@@ -41,20 +42,20 @@
            //多租户会用到这init代码,其他情况可以不用
            //base.Init(dbRepository);
        }
        public WebResponseContent OutsorcingWorkOrder(SaveModel model)
        public WebResponseContent CancelsorcingWorkOrder(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            string compeletor = UserContext.Current.UserName;
            List<string> list = new List<string>();
            try
            {
                List<string> list = new List<string>();
                foreach (var Key in model.DelKeys)
                foreach (var Key in saveModel.DelKeys)
                {
                    var mes_head = _repository.Find(x => x.mes_id.ToString() == Key.ToString()).FirstOrDefault();
                    if (mes_head != null)
                    {
                        mes_head.area = "外协";
                        _repository.Update(mes_head, true);
                        mes_head.area = null;
                        _repository.Update(mes_head, x => new { x.area }, true);
                        list.Add(mes_head.jobID);
                    }
                }
@@ -63,7 +64,33 @@
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("指定工单出库外协", $"错误信息:{ex.Message}", "PCS", compeletor);
                WriteDBLog.Error("取消工单出库外协", $"工单编号:{list}\n错误信息:{ex.Message}", "PCS", compeletor);
            }
            return content;
        }
        public WebResponseContent OutsorcingWorkOrder(SaveModel model)
        {
            WebResponseContent content = new WebResponseContent();
            string compeletor = UserContext.Current.UserName;
            List<string> list = new List<string>();
            try
            {
                foreach (var Key in model.DelKeys)
                {
                    var mes_head = _repository.Find(x => x.mes_id.ToString() == Key.ToString()).FirstOrDefault();
                    if (mes_head != null)
                    {
                        mes_head.area = "外协";
                        _repository.Update(mes_head, x => new { x.area }, true);
                        list.Add(mes_head.jobID);
                    }
                }
                content.OK();
                WriteDBLog.Success("指定工单出库外协", $"工单编号:{list}", "PCS", compeletor);
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("指定工单出库外协", $"工单编号:{list}\n错误信息:{ex.Message}", "PCS", compeletor);
            }
            return content;
        }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs
@@ -19,6 +19,9 @@
using WIDESEA_WCS.IRepositories;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using WIDESEA_Core.EFDbContext;
using WIDESEA_WCS.Repositories;
using WIDESEA_Comm;
namespace WIDESEA_WCS.Services
{
@@ -39,29 +42,50 @@
            //多租户会用到这init代码,其他情况可以不用
            //base.Init(dbRepository);
        }
        /// <summary>
        /// æ¨¡å¼1
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public WebResponseContent UpdateAuto(string v)
        {
            WebResponseContent content = new WebResponseContent();
            VOLContext context = new VOLContext();
            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
            var stations = stationinfoRepository.Find(x => x.stationCode == "X01001001" || x.stationCode == "X01001002" || x.stationCode == "X02001001" || x.stationCode == "X02001002").ToList();
            if (stations.Where(x => x.tray_status == TrayStateEnum.StrogeTray.ToString()).Any())
                return content.Error("设置为模式1失败!下料位存在车轮!");
            var model = JsonConvert.DeserializeObject<dt_pattern>(v);
            model.pattern_state = 1;
            var cont = _repository.Update(model, true);
            if (cont > 0)
                content.OK(model.pattern_name + "设置为自动入库成功!");
                content.OK(model.pattern_name + "设置为模式1成功!");
            else
                content.Error(model.pattern_name + "设置为自动入库失败!");
                content.Error(model.pattern_name + "设置为模式1失败!");
            return content;
        }
        /// <summary>
        /// æ¨¡å¼2
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public WebResponseContent UpdateManual(string v)
        {
            WebResponseContent content = new WebResponseContent();
            VOLContext context = new VOLContext();
            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
            var stations = stationinfoRepository.Find(x => x.stationCode == "X01001001" || x.stationCode == "X01001002" || x.stationCode == "X02001001" || x.stationCode == "X02001002").ToList();
            if (stations.Where(x => x.tray_status == TrayStateEnum.StrogeTray.ToString()).Any())
                return content.Error("设置为模式2失败!下料位存在车轮!");
            var model = JsonConvert.DeserializeObject<dt_pattern>(v);
            model.pattern_state = 0;
            var cont = _repository.Update(model, true);
            if (cont > 0)
                content.OK(model.pattern_name + "设置为手动入库成功!");
                content.OK(model.pattern_name + "设置为模式2成功!");
            else
                content.Error(model.pattern_name + "设置为手动入库失败!");
                content.Error(model.pattern_name + "设置为模式2失败!");
            return content;
        }
  }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WebApi/Controllers/WIDESEA_WCS/Partial/dt_mes_headController.cs
@@ -49,5 +49,11 @@
        {
            return Service.OutsorcingWorkOrder(saveModel);
        }
        [HttpPost, Authorize, Route("CancelsorcingWorkOrder"), AllowAnonymous]
        public WebResponseContent CancelsorcingWorkOrder([FromBody] SaveModel saveModel)
        {
            return Service.CancelsorcingWorkOrder(saveModel);
        }
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_Entity/DomainModels/ToMES/VV_Mes_Workinfo.cs
@@ -17,7 +17,7 @@
    public partial class VV_Mes_Workinfo : BaseEntity
    {
        /// <summary>
        ///工单编号
        ///
        /// </summary>
        [Display(Name = "jobID")]
        [MaxLength(40)]
@@ -26,7 +26,7 @@
        public string jobID { get; set; }
        /// <summary>
        ///炉代号
        ///炉号
        /// </summary>
        [Display(Name = "heatID")]
        [MaxLength(20)]
@@ -35,7 +35,7 @@
        public string heatID { get; set; }
        /// <summary>
        ///钢坯号
        ///
        /// </summary>
        [Display(Name = "billetID")]
        [Column(TypeName = "int")]
@@ -88,7 +88,7 @@
        public string reqIDLineNo { get; set; }
        /// <summary>
        ///物料编码
        ///
        /// </summary>
        [Display(Name = "materialCode")]
        [MaxLength(20)]
@@ -106,7 +106,7 @@
        public string drawingNo { get; set; }
        /// <summary>
        ///技术状态
        ///
        /// </summary>
        [Display(Name = "drawingNoVer")]
        [MaxLength(10)]
@@ -115,7 +115,7 @@
        public string drawingNoVer { get; set; }
        /// <summary>
        ///产品名称
        ///
        /// </summary>
        [Display(Name = "productName")]
        [MaxLength(40)]
@@ -137,7 +137,7 @@
        [Display(Name = "quantity")]
        [Column(TypeName = "int")]
        [Editable(true)]
        public int? quantity { get; set; }
        public int quantity { get; set; }
        /// <summary>
        ///
@@ -149,7 +149,7 @@
        public string typeID { get; set; }
        /// <summary>
        ///
        ///打包数量
        /// </summary>
        [Key]
        [Display(Name = "stackNoRange")]
@@ -159,7 +159,7 @@
        public int stackNoRange { get; set; }
        /// <summary>
        ///工单类型 (17-机加工 28-检测线 101-移库外协)
        ///工单类型 (17-机加工 28-检测线 101移库外协)
        /// </summary>
        [Display(Name = "processCode")]
        [MaxLength(20)]
@@ -167,6 +167,36 @@
        [Editable(true)]
        public string processCode { get; set; }
        /// <summary>
        ///完成数量
        /// </summary>
        [Display(Name = "完成数量")]
        [Column(TypeName = "int")]
        [Editable(true)]
        public int? finishNum { get; set; }
        /// <summary>
        ///创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        [Column(TypeName = "datetime")]
        public DateTime CreateTime { get; set; }
        /// <summary>
        ///完成时间
        /// </summary>
        [Display(Name = "完成时间")]
        [Column(TypeName = "datetime")]
        [Editable(true)]
        public DateTime? FinishTime { get; set; }
        /// <summary>
        ///工单状态
        /// </summary>
        [Display(Name = "工单状态")]
        [MaxLength(20)]
        [Column(TypeName = "nvarchar(20)")]
        [Editable(true)]
        public string Status { get; set; }
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/EmptyPalletTask.cs
@@ -9,7 +9,6 @@
using WIDESEA_Core.EFDbContext;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.JobsPart.Common;
using WIDESEA_WCS.Repositories;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/SendFromaddress.cs
@@ -9,7 +9,6 @@
using WIDESEA_Common;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Entity.ToAGV;
using WIDESEA_WCS.JobsPart.Common;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/SendToaddress.cs
@@ -9,7 +9,6 @@
using WIDESEA_Common;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Entity.ToAGV;
using WIDESEA_WCS.JobsPart.Common;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/GetStation/EmptyPalletStation.cs
@@ -11,7 +11,7 @@
using WIDESEA_WMS.Repositories;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WCS.JobsPart.Common
namespace WIDESEA_WMS.Common
{
    public class GetStation
    {
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/GetStation/EmptyTrayIn.cs
@@ -11,7 +11,7 @@
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
namespace WIDESEA_WCS.JobsPart.Common
namespace WIDESEA_WMS.Common
{
    public class EmptyTray
    {
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/OutboundTask.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Extensions;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Repositories;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using static FreeSql.Internal.GlobalFilter;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WMS.Common
{
    public class OutboundTask
    {
        /// <summary>
        /// åˆ›å»ºå‡ºåº“队列任务
        /// </summary>
        public static void CreateOutboundTask()
        {
            try
            {
                VOLContext context = new VOLContext();
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
                var Mes_Works = workinfoRepository.Find(x => x.processCode == "28").OrderByDescending(x => x.CreateTime).ToList();
                foreach (var Mes_Work in Mes_Works)
                {
                    var inventory = inventoryRepository.Find(x => x.SN == Mes_Work.SN).FirstOrDefault();
                    if (inventory != null)
                    {
                        var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();//查找库存货位
                        if (Station != null)
                        {
                            #region
                            dt_stationinfo stationinfo = null;
                            //查找当前货位同行是否存在入库任务
                            if (GetStation.InBusyStation(Station.stationCode)) continue;
                            stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
                            if (stationinfo != null)
                            {
                                if (agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).Any()) continue;
                                if (stationinfoRepository.Find(x => x.line == stationinfo.line && x.area == stationinfo.area && x.column > stationinfo.column && !x.enable).Any())
                                    continue;
                                if (string.IsNullOrEmpty(stationinfo.bindSN))
                                {
                                    stationinfo.remark = "车轮SN号信息异常";
                                    stationinfo.location_state = "Abnormal";
                                    stationinfoRepository.Update(stationinfo, true);
                                    continue;
                                }
                                if (agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).Any()) continue;
                                List<string> lists = new List<string>();
                                var SNS = stationinfo.bindSN.Split(",");
                                foreach (var SN in SNS)
                                {
                                    if (!string.IsNullOrEmpty(SN))
                                        lists.Add(SN);
                                }
                                #region è´§ä½è½¦è½®å…¨éƒ¨åŒ…含在工单内则下发任务
                                var count = 0;
                                foreach (var SN in lists)
                                {
                                    if (workinfoRepository.Find(x => x.processCode == "28" && x.SN == SN).Any()) count++;
                                    //if (workinfoRepository.Find(x => x.processCode == "28" && x.SN.Contains(SN)).Any()) count++;
                                }
                                if (count != lists.Count) continue;
                                dt_agvtask agvtask = new dt_agvtask()
                                {
                                    agv_fromaddress = stationinfo.stationCode,
                                    agv_id = Guid.NewGuid(),
                                    agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                    agv_grade = 2,
                                    agv_createtime = DateTime.Now,
                                    agv_taskstate = "Queue",
                                    agv_materielid = stationinfo.stationType,
                                    agv_qty = stationinfo.quantity,
                                    agv_tasktype = "TaskType_Outbound",
                                    agv_toaddress = "",
                                    agv_userid = "系统",
                                    bindSN = stationinfo.bindSN,
                                    jobID = Mes_Work.workOrder,
                                    agv_worktype = Convert.ToInt32(Mes_Work.processCode),
                                    agv_materbarcode = Mes_Work.materialCode,
                                    agv_Traytype = stationinfo.tray_type,
                                    agv_TrayStatus = stationinfo.tray_status
                                };
                                stationinfo.location_state = LocationStateEnum.OutBusy.ToString();
                                stationinfoRepository.Update(stationinfo, true);
                                agvtaskRepository.Add(agvtask, true);
                                WriteDBLog.Success("创建出库任务", $"任务编号:{agvtask.agv_tasknum}", "PCS");
                                continue;
                                #endregion
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteDBLog.Error("创建出库任务", $"错误信息:{ex.Message}", "PCS");
            }
        }
    }
}
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs
@@ -5,11 +5,12 @@
{
    public class JobQueueTask : Job
    {
        [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 2, IsEnabled = true, SkipWhileExecuting = true)]
        [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 3, IsEnabled = true, SkipWhileExecuting = true)]
        public void QueueTaskTiem()
        {
            QueueTask.ReplaceTrayTask();
            ToMes.InfoToMes();
            OutboundTask.CreateOutboundTask();
        }
    }
}