wxw
2024-12-23 bdb2bfbe94a1ff091ac5ae379ea01f25f359fc83
修改问题
13个文件已修改
1132 ■■■■ 已修改文件
HTML/views/ASNSetting/ArrivalNoticeDetail.html 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/HouseWithinSetting/CRLogTask.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/Login.html 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/QualityControl/QualityInformation.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/QualityControl/QualityInformationFrom.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/SOSetting/ExportNotice.html 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/SOSetting/ExportNoticeAddFrom.html 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/SOSetting/ExportSelectSkuFrom.html 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/index.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Model/InterFaceModel/RCSModel.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs 148 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllTransServer/RcsServer.cs 705 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/ASNSetting/ArrivalNoticeDetail.html
@@ -61,24 +61,12 @@
                <select name="Type" id="Type" lay-filter="Type" lay-search>
                    <!-- JC23 -->
                    <!-- <option value="0">成品入库</option> -->
                    <option value="1">原料入库</option>
                    <!-- <option value="1">原料入库</option> -->
                    <!-- <option value="4">车间余料退回入库</option>
                    <option value="5">其它入库</option>
                    <option value="6">代储入库</option> -->
                    <!-- <option value=""></option> -->
                    <!-- JC24 -->
                    <!-- <option value="0" selected>成品入库</option>
                    <option value="1">采购入库</option>
                    <option value="2">中间品入库</option> -->
                    <!-- <option value="3">退货入库</option> -->
                    <!-- <option value="4">车间余料退回入库</option>
                    <option value="5">其它入库</option>
                    <option value="6">代储入库</option>
                    <option value="7">寄存入库</option> -->
                    <!-- JC08 -->
                    <!-- <option value="0">成品入库</option>
                    <option value="1">原料入库</option>
                    <option value="2">退货入库</option> -->
                </select>
            </div>
HTML/views/HouseWithinSetting/CRLogTask.html
@@ -305,7 +305,7 @@
                        templet: '#IsSuccessButton',
                    }, {
                        field: 'PalletNo',
                        title: '托盘号',
                        title: '桶号',
                        width: 110,
                        align: 'center',
                    }, {
HTML/views/Login.html
@@ -3,9 +3,9 @@
<head>
    <meta charset="utf-8">
    <title>博柯莱·仓储管理系统</title>
    <meta name="keywords" content="博柯莱·仓储管理系统">
    <meta name="description" content="博柯莱·仓储管理系统">
    <title>博柯莱·AGV转运系统</title>
    <meta name="keywords" content="博柯莱·AGV转运系统">
    <meta name="description" content="博柯莱·AGV转运系统">
    <!-- <link rel="shortcut icon" type="image/ico" href="../img/河北博柯莱-logo01.png" /> -->
    <!-- <link rel="bookmark" type="image/ico" href="../img/favicon.ico" /> -->
    <link href="../layuiadmin/layui/css/layui.css" rel="stylesheet" />
@@ -20,17 +20,17 @@
<body>
    <div class="elight-product-box animated fadeInUp">
        <h2>博柯莱·仓储管理系统</h2>
        <!-- <h2>博柯莱·转运系统</h2>
        <ul class="product-desc">
            <li>“博柯莱·仓储管理系统”简称“WMS系统”,WMS是智能仓库管理系统(Warehouse Management System) 的缩写。</li>
            <li>WMS系统是一个实时的、完善的企业级仓储信息管理系统。</li>
            <li>它能够按照运作的业务规则和运算法则,通过入库、出库、移库和拣选等功能,综合批次管理、物料对应、库存盘点、质量管理和即时库存管理等功能的运用,对信息、资源、行为和存货进行完美的管理,使其能最大程度的满足有效产出和精确性的要求。
            </li>
            <li>它通过条码扫描、流水跟踪、任务跟踪等方式有效控制并跟踪仓储业务的全过程,提高仓储物流配送效率,减少仓库作业对人员经验的依赖性。</li>
        </ul>
        </ul> -->
    </div>
    <div class="elight-login-box animated fadeInRight">
        <div class="elight-login-header">博柯莱·仓储管理系统</div>
        <div class="elight-login-header">博柯莱·AGV转运系统</div>
        <div class="elight-login-body">
            <form class="layui-form">
                <div class="layui-form-item">
HTML/views/QualityControl/QualityInformation.html
@@ -363,7 +363,7 @@
                                    InspectNo: field.InspectNo,        
                                    //ASNNo: field.ASNNo,        
                                    LotNo: field.LotNo,
                                    SkuNo: field.SkuNo,
                                    //SkuNo: field.SkuNo,
                                    IsQualified: field.IsQualified,
                                };
                                if(doing)
HTML/views/QualityControl/QualityInformationFrom.html
@@ -28,12 +28,12 @@
                    <input type="text" name="LotNo" placeholder="请输入批次号" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
            <!-- <div class="layui-form-item">
                <label class="layui-form-label">物料号</label>
                <div class="layui-input-block" style="width: 70%;">
                    <input type="text" name="SkuNo" placeholder="请输入物料号" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            </div> -->
            <div class="layui-form-item">
                    <label class="layui-form-label">审核状态</label>
                    <div class="layui-input-block" style="width: 70%;">
HTML/views/SOSetting/ExportNotice.html
@@ -326,51 +326,14 @@
                <script type="text/html" id="table-content-list">
                        {{# function GetBtn1(d){
                                var html = ''; 
                                if(d.IsWave == '0'){
                                    if(d.Status == '0' || d.Status == '1' ){
                                        if(d.Type != "8" && d.Type != "2") {
                                            html += `<a class="layui-btn layui-btn-normal layui-btn-xs zifenClass" lay-event="auto">
                                                <i class="layui-icon layui-icon-ok"></i>自动分配
                                            </a>`;
                                        }
                                    }
                                if(d.IsWave == '0'){
                                    if(d.Status == '0' && d.Origin == 'WMS'){
                                        html += `<a class="layui-btn layui-btn-normal layui-btn-xs uptClass" lay-event="edit">
                                                    <i class="layui-icon layui-icon-edit"></i>编辑
                                                </a>
                                                <a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="delete">
                                        html += `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="delete">
                                                    <i class="layui-icon layui-icon-delete"></i>删除
                                                </a>`;
                                    }
                                    if(d.Status == '1' || d.Status == '2'){
                                        html += `<a class="layui-btn layui-btn-danger layui-btn-xs qufenClass" lay-event="cancel">
                                                    <i class="layui-icon layui-icon-delete"></i>取消分配
                                                </a>`;
                                    }
                                    if(d.Type == "1" && (d.Status == '2' || d.Status == '3')){
                                        html += `<a class="layui-btn layui-btn-normal layui-btn-xs outClass" lay-event="beiLiaoOutKu">
                                            <i class="layui-icon layui-icon-ok"></i>备料
                                        </a>`;
                                    }
                                    if( d.Status == '2' || d.Status == '3'){
                                        html += `<a class="layui-btn layui-btn-normal layui-btn-xs outClass" lay-event="outKu">
                                                    <i class="layui-icon layui-icon-ok"></i>出库
                                                </a>`;
                                    }
                                }
                                if( d.Status == '4'){
                                    html += `<a class="layui-btn layui-btn-normal layui-btn-xs guanClass" lay-event="finish">
                                                <i class="layui-icon layui-icon-ok"></i>关单
                                            </a>`;
                                }
                                if( d.Status == '5'){
                                    html += `<a class="layui-btn layui-btn-normal layui-btn-xs checkClass" lay-event="check">
                                        <i class="layui-icon layui-icon-ok"></i>复核
                                    </a>`;
                                }
                                html += `<a class="layui-btn layui-btn-normal layui-btn-xs shangClass" lay-event="xml">
                                    <i class="layui-icon layui-icon-ok"></i>XML
                                </a>`;
                                html += `<a class="layui-btn layui-btn-normal layui-btn-xs editDemoClass" lay-event="editDemo">
                                    <i class="layui-icon layui-icon-edit"></i>备注</a>`;
                                return html;
@@ -488,7 +451,7 @@
                { field: 'UpdateTime', title: '修改时间', align: 'center', templet: '#templetUpdateTime' },
                { field: 'CheckUserName', title: '复核人', align: 'center', width: 110 },
                { field: 'CheckTime', title: '复核时间', align: 'center', templet: '#templetCheckTime' },
                //{ field: 'caozuo', title: '操作', fixed: 'right', align: 'center', width: 200, toolbar: '#table-content-list', "disabled": false }
                { field: 'caozuo', title: '操作', fixed: 'right', align: 'center', width: 200, toolbar: '#table-content-list', "disabled": false }
            ]];
            var TotalColsSysArr = encodeURIComponent(encodeURIComponent(JSON.stringify(TotalColsArr)))//将表头数据进行url编码
            //#endregion
HTML/views/SOSetting/ExportNoticeAddFrom.html
@@ -34,36 +34,16 @@
                        <select name="Type" id="Type" lay-filter="Type" lay-verify="required" lay-search>
                            <!-- <option value=""></option> -->
                            <!-- 23 -->
                            <!-- <option value="0">成品出库</option> -->
                            <option value="1">领料出库</option>
                            <!-- <option value="2">抽检出库</option>
                            <option value="4">不合格品出库</option>
                            <option value="6">代储出库</option>
                            <option value="7">其他出库</option> -->
                            <!-- 24 -->
                            <!-- <option value="0">成品出库</option>
                            <option value="1">领料出库</option>
                            <option value="2">抽检出库</option>
                            <option value="3">物料取样出库</option>
                            <option value="4">不合格品出库</option>
                            <option value="5">中间品出库</option>
                            <option value="6">代储出库</option>
                            <option value="7">其他出库</option>
                            <option value="8">寄存出库</option> -->
                            <!-- 09 -->
                            <!-- <option value="0">标准销售出库</option>
                            <option value="1">非标销售出库</option>
                            <option value="2">标准调拨出库</option>
                            <option value="3">非标调拨出库</option> -->
                            <!-- 08 -->
                            <!-- <option value="0">成品出库</option>
                            <option value="1">原辅料出库</option>
                            <option value="2">不合格品出库</option>
                            <option value="3">取样出库</option> -->
                            <option value="6">代储出库</option> -->
                            <option value="7">其他出库</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                <!-- <div class="layui-inline">
                    <label class="layui-form-label" id="CustomerNamep">客户名称</label>
                    <div class="layui-input-inline">
                        <select name="CustomerNo" id="CustomerNo" lay-search>
@@ -78,7 +58,7 @@
                            <option value=""></option>
                        </select>
                    </div>
                </div>
                </div> -->
                <div class="layui-inline">
                    <div style="padding-bottom: 2px;margin-left: 15px;">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" data-type="add">添加明细</button>
@@ -172,27 +152,31 @@
                    limits: pageLimits,
                    cellMinWidth: 60, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    cols: [
                        [{
                            field: 'SkuNo',
                            title: '物品编码',
                            align: 'center',
                            fixed: 'left',
                            width:140,
                        }, {
                            field: 'SkuName',
                            title: '物品名称',
                            align: 'center',
                            fixed: 'left',
                        }, {
                        [
                        //     {
                        //     field: 'SkuNo',
                        //     title: '物品编码',
                        //     align: 'center',
                        //     fixed: 'left',
                        //     width:140,
                        // }, {
                        //     field: 'SkuName',
                        //     title: '物品名称',
                        //     align: 'center',
                        //     fixed: 'left',
                        // },
                        {
                            field: 'LotNo',
                            title: '批次',
                            align: 'center', 
                            minWidth:140,
                        }, {
                            field: 'Standard',
                            title: '物品规格',
                            align: 'center',
                        }, {
                        },
                        // {
                        //     field: 'Standard',
                        //     title: '物品规格',
                        //     align: 'center',
                        // },
                        {
                            field: 'Qty',
                            title: '库存数量',  
                            align: 'center',
@@ -422,11 +406,11 @@
                            return;
                        }
                        var item = {
                            SkuNo: infoOptions.data[i].SkuNo,
                            //SkuNo: infoOptions.data[i].SkuNo,
                            LotNo: infoOptions.data[i].LotNo,
                            Qty: parseInt(infoOptions.data[i].ExQty),
                            IsBale:infoOptions.data[i].IsBale,
                            IsBelt:infoOptions.data[i].IsBelt,
                            //IsBale:infoOptions.data[i].IsBale,
                            //IsBelt:infoOptions.data[i].IsBelt,
                        };
                        DataList.push(item); //属性
                    }
HTML/views/SOSetting/ExportSelectSkuFrom.html
@@ -99,28 +99,31 @@
                                type: 'radio',
                                width: 50,
                                fixed: 'left'
                            }, {
                                field: 'SkuNo',
                                title: '物品编码',
                                width: 100,
                                align: 'center',
                                fixed: 'left'
                            }, {
                                field: 'SkuName',
                                title: '物品名称',
                                align: 'center',
                                width: 250,
                            }, {
                            },
                            //  {
                            //     field: 'SkuNo',
                            //     title: '物品编码',
                            //     width: 100,
                            //     align: 'center',
                            //     fixed: 'left'
                            // }, {
                            //     field: 'SkuName',
                            //     title: '物品名称',
                            //     align: 'center',
                            //     width: 250,
                            // },
                            {
                                field: 'LotNo',
                                align: 'center',
                                title: '批次',
                                width: 100
                            }, {
                                field: 'Standard',
                                title: '物品规格',
                                align: 'center',
                                minWidth: 100
                            }, {
                                title: '批次'
                            },
                            //  {
                            //     field: 'Standard',
                            //     title: '物品规格',
                            //     align: 'center',
                            //     minWidth: 100
                            // },
                            {
                                field: 'Qty',
                                title: '库存数量',
                                width: 100,
HTML/views/index.html
@@ -2,7 +2,7 @@
<html>
    <head>
        <meta charset="utf-8">
        <title>仓储管理系统</title>
        <title>AGV转运系统</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
@@ -66,7 +66,7 @@
                <div class="layui-side layui-side-menu" id="leftmenu">
                    <div class="layui-side-scroll">
                        <div class="layui-logo" lay-href="home/console.html" style="background-color: #FFFFFF;">
                            <span>博柯莱·仓储管理系统</span>
                            <span>博柯莱·AGV转运系统</span>
                        </div>
                        <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
                            
Wms/Model/InterFaceModel/RCSModel.cs
@@ -28,7 +28,7 @@
        public class Pallnetmsg
        {
            /// <summary>
            /// 设备所在位置(起始位置/目标位置)
            /// 设备所在位置(起始位置/目标位置),设备编码
            /// </summary>
            public string Location { get; set; }
            /// <summary>
@@ -70,8 +70,13 @@
            /// 任务类型 
            /// 0:申请储位
            /// 1:叫桶
            /// 2:同车间平层搬运
            /// </summary>
            public string Crtype { get; set; }
            /// <summary>
            /// 车间编码
            /// </summary>
            public string WareHouseNo { get; set; }
        }
    }
}
Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
@@ -95,98 +95,38 @@
            {
                throw new Exception("质检号不可为空,请核查!");
            }
            //验证物料号是否为空
            if (string.IsNullOrEmpty(model.SkuNo))
            {
                throw new Exception("物料号不可为空,请核查!");
            }
            //获取物料信息
            var sku = Db.Queryable<SysMaterials>().First(a => a.IsDel == "0" && a.SkuNo == model.SkuNo);
            if (sku == null)
            {
                throw new Exception("物料信息为空,请核查!");
            }
            //验证批次号是否为空
            if (string.IsNullOrEmpty(model.LotNo))
            {
                throw new Exception("批次号不可为空,请核查!");
            }
            //int isTui = 0;
            //验证入库单号是否为空
            if (!string.IsNullOrEmpty(model.ASNNo))
            {
                //查询是否为退货入库单据
                var Arrival = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.ASNNo && a.Type == "3");
                if (Arrival == null)
                {
                    throw new Exception("只有入库单据为退货入库单可输入 入库单号,请核查!");
                }
                //获取入库单明细
                var ArrivalDetail = Db.Queryable<BllArrivalNoticeDetail>().First(a => a.IsDel == "0" && a.ASNNo == model.ASNNo && a.LotNo.Contains(model.LotNo) && a.SkuNo == model.SkuNo);
                if (ArrivalDetail == null)
                {
                    throw new Exception("输入的批次或物料信息与入库单据不符,请核查!");
                }
                //isTui = 1;
            }
            //查找质检信息中是否存在同批次质检录入记录
            //BllQualityInspect quality = Db.Queryable<BllQualityInspect>().First(m => m.IsDel == "0" && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo);
            //if (quality != null)
            //{
                ////判断是否为退货入库单
                //if (isTui == 1)
                //{
                //    if (quality.ASNNo == model.ASNNo)
                //    {
                //        throw new Exception("当前退货入库单已创建质检信息,请勿重复创建!");
                //    }
                //}
            //    throw new Exception("当前物料和批次已进行质检,请核查!");
            //}
            ////查找同批次 同单据 入库单信息、
            //BllArrivalNoticeDetail arrivalDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.ASNNo == model.ASNNo && m.LotNo == model.LotNo);
            model.Origin = "WMS"; //来源
            model.CreateTime = Db.GetDate(); //创建日期
            model.SkuNo = sku.SkuNo; //物料号
            model.SkuName = sku.SkuName; //物料名称
            model.SkuNo = ""; //物料号
            model.SkuName = ""; //物料名称
            model.PassQty = 0; //合格数量
            model.FailQty = 0; //不合格数量
            model.Standard = sku.Standard; //规格
            //model.SupplierLot = arrivalDetail.SupplierLot; //供货批次
            model.Standard = ""; //规格
            //查找库存明细信息
            List<DataStockDetail> detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo).ToList();
            List<DataStockDetail> detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.LotNo == model.LotNo).ToList();
            foreach (var item in detail)
            {
                List<BllBoxInfo> box = Db.Queryable<BllBoxInfo>().Where(a => a.IsDel == "0" && a.SkuNo == model.SkuNo && a.LotNo == model.LotNo).ToList();
                //判断合格状态是否合格
                if (model.IsQualified == "1")
                {
                    //合格 相同批次库存信息全部改为合格状态 且合格数量增加为同批次同单号该物料全部数量之和
                    //合格
                    model.PassQty += item.Qty;
                    //修改库存明细合格状态
                    item.InspectStatus = "1"; //1合格
                    //foreach (var b1 in box)
                    //{
                    //    b1.InspectMark = "1"; //1合格
                    //}
                }
                else //不合格
                {
                    //不合格 相同批次、入库单库存信息全部改为不合格物料 且不合格数量增加为同批次同单号该物料全部数量之和
                    //不合格
                    model.FailQty += item.Qty;
                    item.InspectStatus = "2"; //2不合格
                    //foreach (var b1 in box)
                    //{
                    //    b1.InspectMark = "2"; //2不合格
                    //}
                }
                Db.Updateable(box).ExecuteCommand();
                Db.Updateable(item).ExecuteCommand();
            }
            var isquality = Db.Insertable(model).ExecuteCommand();
Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
@@ -959,10 +959,11 @@
                Expression<Func<DataStockDetail, bool>> item = Expressionable.Create<DataStockDetail>()
                    //.And(it => it.WareHouseNo == wareHouseNo)
                    .AndIF(!string.IsNullOrWhiteSpace(inspectStatus), it => inspectStatus.Contains(it.InspectStatus))
                    .And(m => skuStrList.Contains(m.SkuNo))
                    //.And(m => skuStrList.Contains(m.SkuNo))
                    .AndIF(type == "6", m => m.OwnerNo == ownerNo)//代储出库需要关联货主
                    .AndIF(!string.IsNullOrWhiteSpace(msg), it => (it.SkuNo.Contains(msg) || it.SkuName.Contains(msg) || it.LotNo.Contains(msg)))
                    .And(it => (it.Qty - it.LockQty - it.FrozenQty) > 0)
                    //.And(it => (it.Qty - it.LockQty - it.FrozenQty) > 0)
                    .And(it=>!string.IsNullOrEmpty(it.LotNo))
                    .And(it => (it.Status == "0" || it.Status == "1"))
                    .ToExpression();//注意 这一句 不能少
                //库存明细
@@ -1037,14 +1038,7 @@
                if (model == null || model.Detail.Count == 0)
                {
                    throw new Exception("参数异常");
                }
                var skuNos = model.Detail.Select(a => a.SkuNo).Distinct().ToList();
                //根据物料号获取物料信息、库存明细中获取批次描述供货批次等
                var skuList = Db.Queryable<SysMaterials>().Where(a => skuNos.Contains(a.SkuNo) && a.IsDel == "0").ToList();
                var stockList = Db.Queryable<DataStock>().Where(s => skuNos.Contains(s.SkuNo) && (s.Qty - s.FrozenQty - s.LockQty) > 0).ToList();
                //var palletList = contextDb.Queryable<DataStockDetail>().Where(s => skuNos.Contains(s.SkuNo) && (s.Qty - s.FrozenQty - s.LockQty) > 0).ToList();
                //客户信息
                var customer = Db.Queryable<SysCustomer>().Where(m => m.IsDel == "0" && m.CustomerNo == model.CustomerNo).ToList();
                }
                var billNo = "";
                var bl = true;
                do
@@ -1055,111 +1049,58 @@
                    bl = Db.Queryable<BllExportNotice>().Any(m => m.SONo == no);
                } while (bl);
                Db.BeginTran();//开启事务
                try
                {
                    var list = new List<BllExportNoticeDetail>();
                    //添加出库单
                    foreach (var d in model.Detail)
                    foreach (var item in model.Detail)
                    {
                        if (d.Qty < 1)
                        if (item.Qty < 1)
                        {
                            throw new Exception("出库数量必须大于0");
                        }
                        var sku = skuList.FirstOrDefault(a => a.SkuNo == d.SkuNo);
                        if (sku == null)
                        if (string.IsNullOrWhiteSpace(item.LotNo))
                        {
                            throw new Exception($"物料信息中未查询到出库物料信息:{d.SkuNo}");
                            throw new Exception("批次不可为空!");
                        }
                        //0:成品出库、1:领料出库、2:抽检出库、4:不合格品出库、6:代储出库、7:其他出库、 ///3:物料取样出库、5:中间品出库、8:寄存出库
                        if (model.Type == "0" || model.Type == "2" || model.Type == "4" || model.Type == "7")
                        var soNoticeDetail = Db.Queryable<BllExportNoticeDetail>().First(w => w.IsDel == "0" && w.LotNo == item.LotNo);
                        if (soNoticeDetail != null)
                        {
                            if (string.IsNullOrWhiteSpace(d.LotNo))
                            var soNotice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNoticeDetail.SONo && (w.Status == "0" || w.Status == "1" || w.Status == "2" || w.Status == "3"));
                            if (soNotice != null)
                            {
                                throw new Exception("批次不可为空!");
                            }
                        }
                        if (model.Type == "1")
                        {
                            if (list.Count(m=>m.SkuNo == d.SkuNo)>=2)
                            {
                                throw new Exception("领料出库单同单据同物料不允许超过3个批次混批出库");
                            }
                        }
                        else
                        {
                            if (list.Count(m => m.SkuNo == d.SkuNo) >= 1)
                            {
                                throw new Exception("出库单同单据同物料不允许超过2个批次混批出库");
                                throw new Exception($"该批次有未完成的出库单,批次号:{soNoticeDetail.LotNo}!");
                            }
                        }
                        //库存
                        List<DataStock> stocks;
                        var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LotNo == item.LotNo);
                        decimal q1 = 0;
                        Dictionary<int, decimal> dic = new Dictionary<int, decimal>();
                        if (!string.IsNullOrWhiteSpace(d.LotNo))
                        {
                            stocks = stockList.Where(s => s.SkuNo == d.SkuNo && s.LotNo == d.LotNo).ToList();
                        }
                        else
                        {
                            stocks = stockList.Where(s => s.SkuNo == d.SkuNo && string.IsNullOrWhiteSpace(s.LotNo)).ToList();
                        }
                        if (stocks.Count < 1)
                        {
                            throw new Exception($"总库存中未查询到出库物料信息:{d.SkuNo}");
                        }
                        //判断数量
                        var qty = stocks.First().Qty - stocks.First().LockQty - stocks.First().FrozenQty;
                        if (d.Qty > qty)
                        {
                            throw new Exception($"总库存中出库物料信息:{d.SkuNo}、{d.LotNo} 库存数量不足");
                        }
                        var item = new BllExportNoticeDetail()
                        var noticeDetail = new BllExportNoticeDetail()
                        {
                            SONo = billNo,
                            SkuNo = sku.SkuNo,
                            SkuName = sku.SkuName,
                            Standard = sku.Standard,
                            LotNo = d.LotNo,
                            SkuNo = stockDetail.SkuNo,
                            SkuName = stockDetail.SkuName,
                            Standard = stockDetail.Standard,
                            LotNo = stockDetail.LotNo,
                            LotText = "",
                            Status = "0",
                            Qty = d.Qty,
                            Qty = item.Qty,
                            AllotQty = 0,
                            FactQty = 0,
                            CompleteQty = 0,
                            PackagNo = sku.PackagNo,
                            Price = sku.Price,
                            Money = string.IsNullOrWhiteSpace(sku.Price.ToString()) ? null : sku.Price * d.Qty,
                            IsBale = d.IsBale,
                            IsBelt = d.IsBelt,
                            SupplierLot = stocks.First().SupplierLot,
                            IsWave = "0",
                            WaveNo = "",
                            //PackagNo = sku.PackagNo,
                            //Price = sku.Price,
                            //Money = string.IsNullOrWhiteSpace(sku.Price.ToString()) ? null : sku.Price * d.Qty,
                            //IsBale = d.IsBale,
                            //IsBelt = d.IsBelt,
                            //SupplierLot = stocks.First().SupplierLot,
                            //IsWave = "0",
                            //WaveNo = "",
                            CreateUser = userId,
                        };
                        list.Add(item);
                        stocks.First().LockQty += d.Qty;//锁定数量
                        var i = Db.Updateable(stocks.First()).UpdateColumns(it => new { it.LockQty })
                            .ExecuteCommand();
                        //foreach (var s in dic)
                        //{
                        //    var st = stockList.First(m => m.Id == s.Key);
                        //    st.LockQty += s.Value;//锁定数量
                        //    var i = Db.Updateable(st).UpdateColumns(it => new { it.LockQty })
                        //        .ExecuteCommand();
                        //}
                        list.Add(noticeDetail);
                    }
                    var notice = new BllExportNotice()
                    {
@@ -1167,8 +1108,8 @@
                        Type = model.Type,
                        Status = "0",
                        Origin = "WMS",
                        CustomerNo = model.CustomerNo,
                        CustomerName = customer.FirstOrDefault() == null ? "" : customer.First().CustomerName,
                        //CustomerNo = model.CustomerNo,
                        //CustomerName = customer.FirstOrDefault() == null ? "" : customer.First().CustomerName,
                        LogisticsId = model.LogisticsId,
                        IsWave = "0",
                        WaveNo = "",
@@ -1674,37 +1615,16 @@
                    throw new Exception("参数异常,请检查状态是否未等待执行或来源是否是WMS");
                }
                //总库存信息
                var stockList = Db.Queryable<DataStock>().ToList();
                //出库单明细
                var noticeDetail = Db.Queryable<BllExportNoticeDetail>().Where(m => m.IsDel == "0" && m.SONo == notice.SONo).ToList();
                Db.BeginTran();//开启事务
                try
                {
                    foreach (var d in noticeDetail)
                    foreach (var item in noticeDetail)
                    {
                        //总库存
                        var sq = stockList.Where(s => s.SkuNo == d.SkuNo);
                        if (!string.IsNullOrWhiteSpace(d.LotNo))
                        {
                            sq = sq.Where(s => s.LotNo == d.LotNo);
                        }
                        else
                        {
                            sq = sq.Where(s => string.IsNullOrWhiteSpace(s.LotNo));
                        }
                        var fd = sq.FirstOrDefault();
                        if (fd == null)
                        {
                            throw new Exception($"未找到物料{d.SkuNo}、批次{d.LotNo} 的库存信息");
                        }
                        fd.LockQty -= d.Qty;
                        d.IsDel = "1";
                        d.UpdateUser = userId;
                        d.UpdateTime = DateTime.Now;
                        Db.Updateable(d).ExecuteCommand();
                        Db.Updateable(fd).UpdateColumns(it => new { it.LockQty }).ExecuteCommand();
                        item.IsDel = "1";
                    }
                    Db.Updateable(noticeDetail).ExecuteCommand();
                    //删除出库单
                    notice.IsDel = "1";
                    notice.UpdateUser = userId;
Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -42,216 +42,264 @@
                string taskMsg = "";
                if (string.IsNullOrEmpty(model.Location))
                {
                    throw new Exception("设备所在位置不可为空");
                    throw new Exception("设备编码不可为空");
                }
                //叫桶设备所在储位信息(目标储位)
                var endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.Location);
                if (endLoction == null)
                //通过设备号查找到所属设备(区域)
                var deviceInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == model.Location);
                if (deviceInfo == null)
                {
                    throw new Exception("设备储位信息不存在");
                    throw new Exception("设备信息不存在");
                }
                var houseNo = endLoction.WareHouseNo;//叫桶位置,后续根据位置关联或定义,来判断叫桶位置所属车间
                var houseNo = deviceInfo.WareHouseNo;//叫桶设备所属车间编号
                //叫桶设备所在储位信息(目标储位)
                var endLoction = new SysStorageLocat();
                var urlMes = "";//回传MES的接口地址
                var noticeNo = "0";//出入库单据明细ID
                var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0");//所有待分配的桶
                //所有待分配的桶
                var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0");
                //分配桶信息
                var pallet = new DataStockDetail();
                //开始事务
                Db.BeginTran();
                DataStockDetail pallet = new DataStockDetail();
                switch (model.Type)
                {
                    case "0"://叫净桶
                        //查找到该车间净桶区
                        List<string> areaNoList = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "0" && w.WareHouseNo == houseNo).Select(s=>s.AreaNo).ToList();
                        //查找净桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "0" && w.Status == "0"
                        && areaNoList.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (pallet == null)
                    case "0"://接料设备叫净桶
                        {
                            throw new Exception("暂无净桶可分配");
                            //叫桶目标储位地址信息
                            endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            if (endLoction == null)
                            {
                                throw new Exception("叫桶设备目标储位信息不存在");
                            }
                            //查找到该车间净桶区
                            List<string> areaNoList = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "0" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                            //查找净桶
                            pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "0" && w.Status == "0"
                            && areaNoList.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                            if (pallet == null)
                            {
                                throw new Exception("暂无净桶可分配");
                            }
                            pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                                                //更新桶库存明细
                            Db.Updateable(pallet).ExecuteCommand();
                            taskMsg = "设备叫净桶任务";
                        }
                        break;
                    case "1"://混料设备叫料桶(混料)
                        {
                            //叫桶目标储位地址信息
                            endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            if (endLoction == null)
                            {
                                throw new Exception("叫桶设备目标储位信息不存在");
                            }
                            //判断是否有批次号
                            if (string.IsNullOrWhiteSpace(model.LotNo))
                            {
                                throw new Exception("批次号为空!");
                            }
                            //查找到该车间预混区
                            List<string> areaNoList2 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "1" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                            //查找库存中是否有可用的此批次的混料桶
                            pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "1" && w.Status == "0" && w.LotNo == model.LotNo
                            && areaNoList2.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                            if (pallet == null)
                            {
                                throw new Exception("暂无混料桶可分配");
                            }
                            pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                                                //更新桶库存明细
                            Db.Updateable(pallet).ExecuteCommand();
                            taskMsg = "设备叫料桶混料任务";
                        }
                        break;
                    case "2"://下料设备叫料桶(下料)
                        {
                            if (houseNo == "M04")//除了喷干车间下料口都是2个储位(投料储位、投完料储位)
                            {
                                //叫桶目标储位地址信息
                                endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            }
                            else
                            {
                                //叫桶目标储位地址信息
                                endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo && w.Column == 1);// Column=1 投料储位,Column=2 投完料储位
                            }
                            if (endLoction == null)
                            {
                                throw new Exception("叫桶设备目标储位信息不存在");
                            }
                            //判断是否有批次号
                            if (string.IsNullOrWhiteSpace(model.LotNo))
                            {
                                throw new Exception("批次号为空!");
                            }
                            //查找是否有此批次出库单明细
                            var soNoticeDetail = Db.Queryable<BllExportNoticeDetail>().Where(w => w.IsDel == "0" && w.LotNo == model.LotNo).OrderBy(o => o.CreateTime).First();
                            if (soNoticeDetail == null)
                            {
                                throw new Exception("该批次没有对应的出库单明细");
                            }
                            noticeNo = soNoticeDetail.Id.ToString();
                            //出库总单
                            var soNotice = Db.Queryable<BllExportNotice>().Where(w => w.IsDel == "0" && w.SONo == soNoticeDetail.SONo).First();
                            if (soNotice == null)
                            {
                                throw new Exception("该批次没有对应的出库单");
                            }
                            soNotice.Status = "3";//正在执行
                            soNotice.UpdateTime = DateTime.Now;
                            //更新出库单
                            Db.Updateable(soNotice).ExecuteCommand();
                            //查找到该车间半成品区
                            List<string> areaNoList3 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "2" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                            //查找库存中是否有此批次的合格下料桶
                            pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "2" && w.Status == "0" && w.LotNo == model.LotNo && w.InspectStatus == "1"
                            && areaNoList3.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                            if (pallet == null)
                            {
                                throw new Exception("暂无下料桶可分配");
                            }
                            pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                                                //更新桶库存明细
                            Db.Updateable(pallet).ExecuteCommand();
                            taskMsg = "设备叫料桶下料任务";
                        }
                        break;
                    case "3"://清洗设备叫脏桶
                        {
                            //叫桶目标储位地址信息
                            endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo && w.Column == 1);// Column=1 清洗储位,Column=2 清洗完料储位
                            if (endLoction == null)
                            {
                                throw new Exception("叫桶设备目标储位信息不存在");
                            }
                            //查找到该车间脏桶区
                            List<string> areaNoList4 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "3" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                            List<DataStockDetail> palletList = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "3" && w.Status == "0"
                            && areaNoList4.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).ToList();
                            if (palletList.Count <= 0)
                            {
                                throw new Exception("暂无脏桶可分配");
                            }
                            taskMsg = "设备叫脏桶任务";
                            //遍历库存脏桶,返回MES验证
                            foreach (var item in palletList)
                            {
                                #region 去掉MES
                                //string jsonReq = JsonConvert.SerializeObject(item.PalletNo);
                                //var response = HttpHelper.DoPost(urlMes, jsonReq, "回传MES脏桶编号", "RCS").ToString();
                                //var obj = JsonConvert.DeserializeObject<ReMes>(response);//解析返回数据
                                //if (obj.Success == "0")
                                //{
                                //    if (obj.Result != "1")//不可清洗,将脏桶冻结
                                //    {
                                //        item.Status = "5";//异常冻结
                                //        //修改该桶库存状态
                                //        Db.Updateable(item).ExecuteCommand();
                                //        continue;
                                //    }
                                //    //下发小车任务
                                //    var task2 = new TaskDetial
                                //    {
                                //        Startport = item.LocatNo,
                                //        Endport = model.Location,
                                //        Pallno = item.PalletNo,
                                //        Type = model.Type,
                                //        Crtype = "1",
                                //        Noticedetailno = int.Parse(noticeno),
                                //    };
                                //    CreateLotTask(task2);
                                //    return;
                                //}
                                //else
                                //{
                                //    throw new Exception("回传MES净桶编号失败!");
                                //}
                                #endregion
                                item.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                                                  //更新桶库存明细
                                Db.Updateable(item).ExecuteCommand();
                                //起始储位地址信息
                                var startLoction2 = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == item.LocatNo);
                                if (startLoction2 == null)
                                {
                                    throw new Exception($"起始目标储位信息不存在,桶号:{item.LocatNo}");
                                }
                                taskNo = new Common().GetMaxNo("TK");//任务号
                                var logTaskEntry2 = new LogTask
                                {
                                    TaskNo = taskNo,
                                    Sender = "WMS",
                                    Receiver = "RCS",
                                    //IsSuccess = 1, //是否下发成功 0失败 1成功
                                    SendDate = DateTime.Now,  //发送时间
                                                              //BackDate = DateTime.Now,  //返回时间
                                    StartLocat = item.LocatNo,//起始位置
                                    EndLocat = model.Location,//目标位置
                                    PalletNo = item.PalletNo,//托盘码
                                    IsSend = 1,//是否可再次下发
                                    IsCancel = 1,//是否可取消
                                    IsFinish = 1,//是否可完成
                                    Type = "1",//任务类型 0 入库任务 1 出库任务  2 移库任务
                                    OrderType = "3",//单据类型 0 入库 1 出库 3 移库
                                    Status = "0",//任务状态0:等待执行1正在执行2执行完成
                                    NoticeDetailNo = int.Parse(noticeNo),
                                    Msg = taskMsg, //关键信息
                                };
                                //组织下发小车任务信息
                                var task2 = new TaskDetial
                                {
                                    Taskno = taskNo,//任务号
                                    Startport = item.LocatNo,
                                    Endport = model.Location,
                                    Pallno = item.PalletNo,
                                    Crtype = "1",//叫桶
                                    WareHouseNo = houseNo
                                };
                                //给下车下发任务
                                logTaskEntry2.SendDate = DateTime.Now;//发送时间
                                var agvResult2 = CreateTaskForAgv(task2, url);
                                if (agvResult2)//成功
                                {
                                    //请求成功修改任务表相应字段状态
                                    logTaskEntry2.IsSuccess = 1;
                                    logTaskEntry2.IsSend = 0;
                                    //logTaskEntry2.IsCancel = 0;
                                    logTaskEntry2.BackDate = DateTime.Now;
                                    logTaskEntry2.Status = "1";
                                    Db.Insertable(logTaskEntry2).ExecuteCommand();
                                    startLoction2.Status = "3";//出库中
                                    Db.Updateable(startLoction2).ExecuteCommand();
                                    endLoction.Status = "2";//入库中
                                    Db.Updateable(endLoction).ExecuteCommand();
                                }
                                else//失败
                                {
                                    logTaskEntry2.IsSuccess = 0;
                                    Db.Insertable(logTaskEntry2).ExecuteCommand();
                                }
                                //提交事务
                                Db.CommitTran();
                                return;
                            }
                        }                        
                        pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                        //更新桶库存明细
                        Db.Updateable(pallet).ExecuteCommand();
                        taskMsg = "设备叫净桶任务";
                        break;
                    case "1"://叫料桶(混料)
                        //判断是否有批次号
                        if (string.IsNullOrWhiteSpace(model.LotNo))
                        {
                            throw new Exception("批次号为空!");
                        }
                        //查找到该车间预混区
                        List<string> areaNoList2 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "1" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //查找库存中是否有可用的此批次的混料桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "1" && w.Status == "0" && w.LotNo == model.LotNo
                        && areaNoList2.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                        if (pallet == null)
                        {
                            throw new Exception("暂无混料桶可分配");
                        }
                        pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                        //更新桶库存明细
                        Db.Updateable(pallet).ExecuteCommand();
                        taskMsg = "设备叫料桶混料任务";
                        break;
                    case "2"://叫料桶(下料)
                        //判断是否有批次号
                        if (string.IsNullOrWhiteSpace(model.LotNo))
                        {
                            throw new Exception("批次号为空!");
                        }
                        //查找是否有此批次出库单明细
                        var soNoticeDetail = Db.Queryable<BllExportNoticeDetail>().Where(w => w.IsDel == "0" && w.LotNo == model.LotNo).OrderBy(o => o.CreateTime).First();
                        if (soNoticeDetail == null)
                        {
                            throw new Exception("该批次没有对应的出库单明细");
                        }
                        noticeNo = soNoticeDetail.Id.ToString();
                        //出库总单
                        var soNotice = Db.Queryable<BllExportNotice>().Where(w => w.IsDel == "0" && w.SONo == soNoticeDetail.SONo).First();
                        if (soNotice == null)
                        {
                            throw new Exception("该批次没有对应的出库单");
                        }
                        soNotice.Status = "3";//正在执行
                        soNotice.UpdateTime = DateTime.Now;
                        //更新出库单
                        Db.Updateable(soNotice).ExecuteCommand();
                        //查找到该车间半成品区
                        List<string> areaNoList3 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "2" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //查找库存中是否有此批次的合格下料桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "2" && w.Status == "0" && w.LotNo == model.LotNo && w.InspectStatus=="1"
                        && areaNoList3.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                        if (pallet == null)
                        {
                            throw new Exception("暂无下料桶可分配");
                        }
                        pallet.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                        //更新桶库存明细
                        Db.Updateable(pallet).ExecuteCommand();
                        taskMsg = "设备叫料桶下料任务";
                        break;
                    case "3"://叫脏桶
                        //查找到该车间脏桶区
                        List<string> areaNoList4 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "3" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        List<DataStockDetail> palletList = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "3" && w.Status == "0"
                        && areaNoList4.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).ToList();
                        if (palletList.Count <= 0)
                        {
                            throw new Exception("暂无脏桶可分配");
                        }
                        //遍历库存脏桶,返回MES验证
                        foreach (var item in palletList)
                        {
                            #region 去掉MES
                            //string jsonReq = JsonConvert.SerializeObject(item.PalletNo);
                            //var response = HttpHelper.DoPost(urlMes, jsonReq, "回传MES脏桶编号", "RCS").ToString();
                            //var obj = JsonConvert.DeserializeObject<ReMes>(response);//解析返回数据
                            //if (obj.Success == "0")
                            //{
                            //    if (obj.Result != "1")//不可清洗,将脏桶冻结
                            //    {
                            //        item.Status = "5";//异常冻结
                            //        //修改该桶库存状态
                            //        Db.Updateable(item).ExecuteCommand();
                            //        continue;
                            //    }
                            //    //下发小车任务
                            //    var task2 = new TaskDetial
                            //    {
                            //        Startport = item.LocatNo,
                            //        Endport = model.Location,
                            //        Pallno = item.PalletNo,
                            //        Type = model.Type,
                            //        Crtype = "1",
                            //        Noticedetailno = int.Parse(noticeno),
                            //    };
                            //    CreateLotTask(task2);
                            //    return;
                            //}
                            //else
                            //{
                            //    throw new Exception("回传MES净桶编号失败!");
                            //}
                            #endregion
                            item.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                            //更新桶库存明细
                            Db.Updateable(item).ExecuteCommand();
                            //起始储位地址信息
                            var startLoction2 = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == item.LocatNo);
                            if (startLoction2 == null)
                            {
                                throw new Exception($"起始目标储位信息不存在,桶号:{item.LocatNo}");
                            }
                            taskNo = new Common().GetMaxNo("TK");//任务号
                            var logTaskEntry2 = new LogTask
                            {
                                TaskNo = taskNo,
                                Sender = "WMS",
                                Receiver = "RCS",
                                //IsSuccess = 1, //是否下发成功 0失败 1成功
                                SendDate = DateTime.Now,  //发送时间
                                                          //BackDate = DateTime.Now,  //返回时间
                                StartLocat = item.LocatNo,//起始位置
                                EndLocat = model.Location,//目标位置
                                PalletNo = item.PalletNo,//托盘码
                                IsSend = 1,//是否可再次下发
                                IsCancel = 1,//是否可取消
                                IsFinish = 1,//是否可完成
                                Type = "1",//任务类型 0 入库任务 1 出库任务  2 移库任务
                                OrderType = "3",//单据类型 0 入库 1 出库 3 移库
                                Status = "0",//任务状态0:等待执行1正在执行2执行完成
                                NoticeDetailNo = int.Parse(noticeNo),
                                Msg = taskMsg, //关键信息
                            };
                            //组织下发小车任务信息
                            var task2 = new TaskDetial
                            {
                                Taskno = taskNo,//任务号
                                Startport = item.LocatNo,
                                Endport = model.Location,
                                Pallno = item.PalletNo,
                                Crtype = "1",//叫桶
                            };
                            //给下车下发任务
                            logTaskEntry2.SendDate = DateTime.Now;//发送时间
                            var agvResult2 = CreateTaskForAgv(task2, url);
                            if (agvResult2)//成功
                            {
                                //请求成功修改任务表相应字段状态
                                logTaskEntry2.IsSuccess = 1;
                                logTaskEntry2.IsSend = 0;
                                //logTaskEntry2.IsCancel = 0;
                                logTaskEntry2.BackDate = DateTime.Now;
                                logTaskEntry2.Status = "1";
                                Db.Insertable(logTaskEntry2).ExecuteCommand();
                                startLoction2.Status = "3";//出库中
                                Db.Updateable(startLoction2).ExecuteCommand();
                                endLoction.Status = "2";//入库中
                                Db.Updateable(endLoction).ExecuteCommand();
                            }
                            else//失败
                            {
                                logTaskEntry2.IsSuccess = 0;
                                Db.Insertable(logTaskEntry2).ExecuteCommand();
                            }
                            //提交事务
                            Db.CommitTran();
                            return;
                        }
                        taskMsg = "设备叫脏桶任务";
                        break;
                    default:
                        throw new Exception("任务类型无效");
@@ -289,11 +337,12 @@
                //组织下发小车任务信息
                var task = new TaskDetial
                {
                    Taskno= taskNo,//任务号
                    Taskno = taskNo,//任务号
                    Startport = pallet.LocatNo,//起始位置
                    Endport = model.Location,//目标位置
                    Pallno = pallet.PalletNo,//桶号
                    Crtype = "1",//叫桶
                    WareHouseNo = houseNo//车间编码
                };
                //给下车下发任务
                logTaskEntry.SendDate = DateTime.Now;//发送时间
@@ -349,13 +398,20 @@
                {
                    throw new Exception($"该桶有正在执行的任务,PalletNo:{model.PalletNo}");
                }
                //通过设备号查找到所属设备(区域)
                var deviceInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == model.Location);
                if (deviceInfo == null)
                {
                    throw new Exception("设备信息不存在");
                }
                var houseNo = deviceInfo.WareHouseNo;//申请储位设备所在车间编号
                //设备所在储位信息(起始储位)
                var deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.Location);
                var deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                if (deviceLocatInfo == null)
                {
                    throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}");
                }
                var houseNo = deviceLocatInfo.WareHouseNo;//申请储位设备所在车间编号
                var noticeno = "0";//出入库单据明细ID
                //桶库存信息
                var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == model.PalletNo);
@@ -372,82 +428,114 @@
                switch (model.Type)
                {
                    case "3"://清洗设备申请储位(净桶申请储位)
                        //查找到该车间净桶区
                        //List<string> areaNoList = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "0" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList.Contains(w.AreaNo) && w.Status == "0" && w.Flag == "0").OrderByDescending(o => o.CreateTime).First();
                        loction = GetLocatModel(houseNo, "0");
                        if (loction == null)
                        {
                            throw new Exception("该车间净桶区暂无空余储位");
                        }
                            //设备所在储位信息(起始储位)
                            deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo && w.Column == 2);// Column=1 清洗储位,Column=2 清洗完料储位
                            if (deviceLocatInfo == null)
                            {
                                throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}");
                            }
                            //查找到该车间净桶区;
                            loction = GetLocatModel(houseNo, "0");
                            if (loction == null)
                            {
                                throw new Exception("该车间净桶区暂无空余储位");
                            }
                        taskMsg = "清洗设备(净桶)申请储位任务";
                            taskMsg = "清洗设备(净桶)申请储位任务";
                        }
                        break;
                    case "0"://接料设备申请储位(预混料桶申请储位)
                        //判断是否有批次号
                        if (string.IsNullOrWhiteSpace(model.LotNo))
                        {
                            throw new Exception("批次号为空!");
                        }
                        //查找到该车间预混区
                        //List<string> areaNoList2 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "1" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList2.Contains(w.AreaNo) && w.Status == "0" && w.Flag == "0").OrderByDescending(o => o.CreateTime).First();
                        loction = GetLocatModel(houseNo, "1");
                        if (loction == null)
                        {
                            throw new Exception("该车间预混区暂无空余储位");
                        }
                        palletInfo.LotNo = model.LotNo;//批次号
                        //更新桶库存信息
                        Db.Updateable(palletInfo).ExecuteCommand();
                            //设备所在储位信息(起始储位)
                            deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            if (deviceLocatInfo == null)
                            {
                                throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}");
                            }
                            //判断是否有批次号
                            if (string.IsNullOrWhiteSpace(model.LotNo))
                            {
                                throw new Exception("批次号为空!");
                            }
                            //查找到该车间预混区
                            loction = GetLocatModel(houseNo, "1");
                            if (loction == null)
                            {
                                throw new Exception("该车间预混区暂无空余储位");
                            }
                            palletInfo.LotNo = model.LotNo;//批次号
                                                           //更新桶库存信息
                            Db.Updateable(palletInfo).ExecuteCommand();
                        taskMsg = "接料设备(预混料桶)申请储位任务";
                            taskMsg = "接料设备(预混料桶)申请储位任务";
                        }
                        break;
                    case "1"://混料设备申请储位(半成品桶申请储位)
                        //判断是否有批次号
                        if (string.IsNullOrWhiteSpace(model.LotNo))
                        {
                            throw new Exception("批次号为空!");
                        }
                        //校验此批次是否有入库单
                        var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().Where(w => w.IsDel == "0" && w.Status == "0" && w.LotNo == model.LotNo).OrderByDescending(o => o.CreateTime).First();
                        if (noticeDetail == null)
                        {
                            throw new Exception("该批次没有对应的入库单明细");
                        }
                        noticeno = noticeDetail.Id.ToString();
                        //入库总单
                        var notice = Db.Queryable<BllArrivalNotice>().Where(w => w.IsDel == "0" && w.ASNNo == noticeDetail.ASNNo).First();
                        if (notice == null)
                        {
                            throw new Exception("该批次没有对应的入库单");
                        }
                        notice.Status = "1";//正在执行
                        //更新入库单状态
                        Db.Updateable(notice).ExecuteCommand();
                            //设备所在储位信息(起始储位)
                            deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            if (deviceLocatInfo == null)
                            {
                                throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}");
                            }
                            //判断是否有批次号
                            if (string.IsNullOrWhiteSpace(model.LotNo))
                            {
                                throw new Exception("批次号为空!");
                            }
                            //校验此批次是否有入库单
                            var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().Where(w => w.IsDel == "0" && w.Status == "0" && w.LotNo == model.LotNo).OrderByDescending(o => o.CreateTime).First();
                            if (noticeDetail == null)
                            {
                                throw new Exception("该批次没有对应的入库单明细");
                            }
                            noticeno = noticeDetail.Id.ToString();
                            //入库总单
                            var notice = Db.Queryable<BllArrivalNotice>().Where(w => w.IsDel == "0" && w.ASNNo == noticeDetail.ASNNo).First();
                            if (notice == null)
                            {
                                throw new Exception("该批次没有对应的入库单");
                            }
                            notice.Status = "1";//正在执行
                                                //更新入库单状态
                            Db.Updateable(notice).ExecuteCommand();
                        //查找到该车间半成品区
                        //List<string> areaNoList3 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "2" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList3.Contains(w.AreaNo) && w.Status == "0" && w.Flag == "0").OrderByDescending(o => o.CreateTime).First();
                        loction = GetLocatModel(houseNo, "2");
                        if (loction == null)
                        {
                            throw new Exception("该车间半成品区暂无空余储位");
                        }
                            //查找到该车间半成品区
                            loction = GetLocatModel(houseNo, "2");
                            if (loction == null)
                            {
                                throw new Exception("该车间半成品区暂无空余储位");
                            }
                        taskMsg = "接料设备(混料桶)申请储位任务";
                            taskMsg = "接料设备(混料桶)申请储位任务";
                        }
                        break;
                    case "2"://下料设备申请储位(脏桶申请储位)
                        //查找到该车间脏桶区
                        //List<string> areaNoList4 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "3" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList4.Contains(w.AreaNo) && w.Status == "0" && w.Flag == "0").OrderByDescending(o => o.CreateTime).First();
                        loction = GetLocatModel(houseNo, "3");
                        if (loction == null)
                        {
                            throw new Exception("该车间脏桶区暂无空余储位");
                        }
                            if (houseNo == "M04")//除了喷干车间下料口都是2个储位(投料储位、投完料储位)
                            {
                                //设备所在储位信息(起始储位)
                                deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            }
                            else
                            {
                                //设备所在储位信息(起始储位)
                                deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo && w.Column == 2);//Column=1 投料储位,Column=2 投完料储位
                            }
                            if (deviceLocatInfo == null)
                            {
                                throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}");
                            }
                            //查找到该车间脏桶区
                            loction = GetLocatModel(houseNo, "3");
                            if (loction == null)
                            {
                                throw new Exception("该车间脏桶区暂无空余储位");
                            }
                        taskMsg = "下料设备(脏桶)申请储位任务";
                            taskMsg = "下料设备(脏桶)申请储位任务";
                        }
                        break;
                }
@@ -480,6 +568,7 @@
                    Endport = loction.LocatNo,
                    Pallno = model.PalletNo,
                    Crtype = "0",//入库
                    WareHouseNo = houseNo
                };
                //给下车下发任务
                logTaskEntry.SendDate = DateTime.Now;//发送时间
@@ -748,28 +837,59 @@
                //入库任务,处理入库单
                if (taskInfo.Type == "0" && taskInfo.NoticeDetailNo != 0)
                {
                    var notice = Db.Queryable<BllArrivalNotice>().First(w => w.IsDel == "0" && w.Status == "1");
                    if (notice != null)
                    {
                        notice.Status = "2";//执行完成
                        notice.UpdateTime = DateTime.Now;
                        notice.CompleteTime = DateTime.Now;
                        //修改入库单状态
                        Db.Updateable(notice).ExecuteCommand();
                    //入库单明细
                    var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.IsDel == "0" && w.Id == taskInfo.NoticeDetailNo);
                    if (noticeDetail != null)
                    {
                        noticeDetail.CompleteQty += 1;//完成数量
                        if (noticeDetail.CompleteQty >= noticeDetail.Qty)
                        {
                            noticeDetail.CompleteTime = DateTime.Now;//完成时间
                            //入库单
                            var notice = Db.Queryable<BllArrivalNotice>().First(w => w.IsDel == "0" && w.ASNNo == noticeDetail.ASNNo);
                            var noticeDetailList = Db.Queryable<BllArrivalNoticeDetail>().Where(w => w.IsDel == "0" && w.CompleteQty < w.Qty && w.Id != noticeDetail.Id).ToList();
                            if (noticeDetailList.Count <= 0)
                            {
                                notice.Status = "2";//执行完成
                                notice.UpdateTime = DateTime.Now;
                                notice.CompleteTime = DateTime.Now;
                                //修改入库单状态
                                Db.Updateable(notice).ExecuteCommand();
                            }
                        }
                        //修改入库单明细
                        Db.Updateable(noticeDetail).ExecuteCommand();
                    }
                }
                //出库任务,处理出库单
                if (taskInfo.Type == "1" && taskInfo.NoticeDetailNo != 0)//入库
                {
                    var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.Status == "3");
                    if (notice != null)
                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>().First(w => w.IsDel == "0" && w.Id==taskInfo.NoticeDetailNo);
                    if (noticeDetail != null)
                    {
                        notice.Status = "4";//执行完成
                        notice.UpdateTime = DateTime.Now;
                        notice.CompleteTime = DateTime.Now;
                        //修改入库单状态
                        Db.Updateable(notice).ExecuteCommand();
                        noticeDetail.CompleteQty += 1;//完成数量
                        if (noticeDetail.CompleteQty >= noticeDetail.Qty)
                        {
                            var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == noticeDetail.SONo);
                            var noticeDetailList = Db.Queryable<BllExportNoticeDetail>().Where(w => w.IsDel == "0" && w.CompleteQty < w.Qty && w.Id != noticeDetail.Id).ToList();
                            if (noticeDetailList.Count <= 0)
                            {
                                notice.Status = "4";//执行完成
                                notice.UpdateTime = DateTime.Now;
                                notice.CompleteTime = DateTime.Now;
                                //修改入库单状态
                                Db.Updateable(notice).ExecuteCommand();
                            }
                        }
                        //修改入库单明细
                        Db.Updateable(noticeDetail).ExecuteCommand();
                    }
                }
                #region 去掉MES
@@ -982,7 +1102,11 @@
            {
                path1.type = "05";
            }
            else//申请储位(桶入库)
            else if (taskDetial.Crtype == "0")//申请储位(桶入库)
            {
                path1.type = "00";
            }
            else//同车间平层搬运
            {
                path1.type = "05";
            }
@@ -993,9 +1117,13 @@
            path2.positionCode = taskDetial.Endport;
            if (taskDetial.Crtype == "1")//叫桶(桶出库)
            {
                path2.type = "00";
            }
            else if (taskDetial.Crtype == "1")//申请储位(桶入库)
            {
                path2.type = "05";
            }
            else//申请储位(桶入库)
            else //同车间平层搬运
            {
                path2.type = "05";
            }
@@ -1005,21 +1133,34 @@
            AgvSchedulingTask agvTask = new AgvSchedulingTask();
            agvTask.reqCode = taskDetial.Taskno;//请求编号
            agvTask.taskCode = taskDetial.Taskno;//任务号
            agvTask.ctnrCode = taskDetial.Pallno;//桶号
            agvTask.ctnrTyp = "1";// 1:桶 3:托盘
            agvTask.ctnrCode = taskDetial.Pallno;//桶号
            agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//请求时间                
            agvTask.wbCode = "";
            agvTask.positionCodePath = pahtList;//小车路径
            agvTask.podCode = "";
            agvTask.userCallCode = "";//taskDetial.Endport;//目标位置
            //判断容器类型
            if (taskDetial.WareHouseNo == "M04")//喷干车间
            {
                agvTask.ctnrTyp = "2";// 1:桶 2:桶(小) 3:托盘
            }
            else
            {
                agvTask.ctnrTyp = "1";// 1:桶 2:桶(小) 3:托盘
            }
            //判断任务类型
            if (taskDetial.Crtype == "1")//叫桶(桶出库)
            {
                agvTask.taskTyp = "Z3";//任务类型 线边到托盘收集器 Z1, 托盘垛申请入库 Z2
            }
            else//申请储位(桶入库)
            else if (taskDetial.Crtype == "0")//申请储位(桶入库)
            {
                agvTask.taskTyp = "Z4";//任务类型 线边到托盘收集器 Z1, 托盘垛申请入库 Z2
            }
            else//同车间平层搬运
            {
                agvTask.taskTyp = "Z5";
            }
            // 正式运行程序放开
            var jsonData = JsonConvert.SerializeObject(agvTask);