zhaowc
2 天以前 bb0b78e7ef5317a38adc18a648e41aa8cc4711bc
程序修改
15个文件已修改
739 ■■■■ 已修改文件
HTML/.vscode/settings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/js/public.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/HouseWithinSetting/HopperTransport.html 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/views/StatisticalReport/BoxInfor.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Model/InterFaceModel/HttpModel.cs 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Utility/Tools/RcsHelper.cs 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs 362 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllTransServer/RcsServer.cs 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/SysServer/PalletsServer.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.DAL/Common.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.Entity/DataEntity/DataStockDetail.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.IBLL/IBllTransServer/IRcsServer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Wms/Controllers/DownApiController.cs 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Wms/Properties/launchSettings.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Wms/appsettings.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HTML/.vscode/settings.json
@@ -1,3 +1,3 @@
{
    "liveServer.settings.port": 5503
    "liveServer.settings.port": 5504
}
HTML/js/public.js
@@ -1,9 +1,9 @@
//var IP = "http://47.104.149.73:1991";//接口IP
// var IP = "http://172.16.71.101:8082/";//接口IP
//var IP = "http://localhost:13243/api";
var IP = "http://localhost:50515/api";  //本地
//var IP = "http://192.168.10.203:8090/api";
// var IP = "https://localhost:44323/api";  //本地
//var IP = "http://172.16.105.10:8086/api";
// var IP = "http://localhost:44318/api";
var IP = "http://localhost:58787/api";
//var IP = "http://192.168.1.6:8017";
//var IP = "http://192.168.1.226:8086";  
// var IP = "http://192.168.62.200:8888/api";  //bkl服务器
HTML/views/HouseWithinSetting/HopperTransport.html
@@ -50,6 +50,7 @@
                        <ul class="layui-tab-title" id="tab">
                            <li class="layui-this">叫料</li>
                            <li>叫车</li>
                            <li>车间到车间</li>
                        </ul>
 
                        <div class="layui-tab-content">
@@ -70,7 +71,7 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">区域</label>
                                            <div class="layui-input-block">
                                                <select id="AreaSelect" name="AreaSelect" lay-filter="AreaSelect" lay-search>
                                                <select id="AreaSelect" name="AreaSelect" lay-filter="AreaSelect" >
                                                    <option value=""></option>
                                                </select>
                                                
@@ -80,7 +81,7 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">目标位置</label>
                                            <div class="layui-input-block"> 
                                                <select id="LocateSelect" name="LocateSelect" lay-filter="LocateSelect" lay-search>
                                                <select id="LocateSelect" name="LocateSelect" lay-filter="LocateSelect" >
                                                    <option value=""></option> 
                                                </select>
                                            </div>
@@ -88,7 +89,7 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">桶类型</label>
                                            <div class="layui-input-block">
                                                <select id="PalletStatus" name="PalletStatus" lay-filter="PalletStatus" lay-search>
                                                <select id="PalletStatus" name="PalletStatus" lay-filter="PalletStatus" >
                                                    <option value=""></option>
                                                    <option value="0">净桶</option>
                                                    <option value="2">满桶</option> 
@@ -99,7 +100,7 @@
                                        <div class="layui-form-item" id="StandardDiv">
                                            <label class="layui-form-label" style="width: 80px;">规格</label>
                                            <div class="layui-input-block">
                                                <select name="Standard" lay-filter="Standard" lay-search>
                                                <select name="Standard" lay-filter="Standard" >
                                                    <option value="400L">400L</option> 
                                                    <option value="800L">800L</option> 
                                                    <option value="1000L">1000L</option> 
@@ -109,7 +110,7 @@
                                        <div class="layui-form-item" id="SkuSelectDiv">
                                            <label class="layui-form-label" style="width: 80px;">物料</label>
                                            <div class="layui-input-block">
                                                <select id="SkuSelect" name="SkuSelect" lay-filter="SkuSelect" lay-search>
                                                <select id="SkuSelect" name="SkuSelect" lay-filter="SkuSelect" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
@@ -117,7 +118,7 @@
                                        <div class="layui-form-item" id="LotNoSelectDiv">
                                            <label class="layui-form-label" style="width: 80px;">批次</label>
                                            <div class="layui-input-block">
                                                <select id="LotNoSelect" name="LotNoSelect" lay-filter="LotNoSelect" lay-search>
                                                <select id="LotNoSelect" name="LotNoSelect" lay-filter="LotNoSelect" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
@@ -141,7 +142,7 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">区域</label>
                                            <div class="layui-input-block">
                                                <select id="AreaSelect2" name="AreaSelect2" lay-filter="AreaSelect2" lay-search>
                                                <select id="AreaSelect2" name="AreaSelect2" lay-filter="AreaSelect2" >
                                                    <option value=""></option>
                                                </select>
                                                
@@ -151,7 +152,7 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">起始位置</label>
                                            <div class="layui-input-block"> 
                                                <select id="LocateSelect2" name="LocateSelect2" lay-filter="LocateSelect2" lay-search>
                                                <select id="LocateSelect2" name="LocateSelect2" lay-filter="LocateSelect2" >
                                                    <option value=""></option> 
                                                </select>
                                            </div>
@@ -159,9 +160,9 @@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">桶类型</label>
                                            <div class="layui-input-block">
                                                <select id="PalletStatus2" name="PalletStatus2" lay-filter="PalletStatus2" lay-search>
                                                <select id="PalletStatus2" name="PalletStatus2" lay-filter="PalletStatus2" >
                                                    <option value=""></option>
                                                    <!-- <option value="0">净桶</option> -->
                                                     <option value="0">净桶</option>
                                                    <option value="2">满桶</option> 
                                                    <option value="3">脏桶</option> 
                                                </select>
@@ -180,7 +181,7 @@
                                        <div class="layui-form-item" id="SkuSelectDiv2">
                                            <label class="layui-form-label" style="width: 80px;">物料</label>
                                            <div class="layui-input-block">
                                                <select id="SkuSelect2" name="SkuSelect2" lay-filter="SkuSelect2" lay-search>
                                                <select id="SkuSelect2" name="SkuSelect2" lay-filter="SkuSelect2" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
@@ -212,6 +213,94 @@
                                
                            </div>
                            <div class="layui-tab-item">
                                <div class="flesDiv" >
                                    <form class="layui-form" action="" style="width: 40%;">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">起始区域</label>
                                            <div class="layui-input-block">
                                                <select id="AreaSelect3" name="AreaSelect3" lay-filter="AreaSelect3" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">起始位置</label>
                                            <div class="layui-input-block">
                                                <select id="LocateSelect3" name="LocateSelect3" lay-filter="LocateSelect3" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">目标区域</label>
                                            <div class="layui-input-block">
                                                <select id="AreaSelect4" name="AreaSelect4" lay-filter="AreaSelect4" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">目标位置</label>
                                            <div class="layui-input-block">
                                                <select id="LocateSelect4" name="LocateSelect4" lay-filter="LocateSelect4" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 80px;">桶类型</label>
                                            <div class="layui-input-block">
                                                <select id="PalletStatus2" name="PalletStatus2" lay-filter="PalletStatus2" >
                                                    <option value=""></option>
                                                     <option value="0">净桶</option>
                                                    <option value="2">满桶</option>
                                                    <option value="3">脏桶</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item" id="SkuSelectDiv2">
                                            <label class="layui-form-label" style="width: 80px;">物料</label>
                                            <div class="layui-input-block">
                                                <select id="SkuSelect2" name="SkuSelect2" lay-filter="SkuSelect2" >
                                                    <option value=""></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item" id="LotNoSelectDiv2">
                                            <label class="layui-form-label" style="width: 80px;">批次</label>
                                            <div class="layui-input-block">
                                                <input type="text" id="LotNoInput" name="LotNoInput" placeholder="" autocomplete="off"
                                                    class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item" id="WeightSelectDiv2">
                                            <label class="layui-form-label" style="width: 80px;">重量</label>
                                            <div class="layui-input-block">
                                                <input type="text" id="WeightInput" name="WeightInput" placeholder="" autocomplete="off"
                                                    class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item" >
                                            <div class="layui-input-block">
                                                <button type="submit" class="layui-btn" lay-submit
                                                    lay-filter="demo3">立即提交</button>
                                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
            </div>
@@ -237,6 +326,7 @@
            var laypage = layui.laypage;
            var layer = layui.layer;
            var laydate = layui.laydate;
            var a = 0;
            var bodyHeight = $("#body").outerHeight(); 
@@ -289,17 +379,26 @@
                });
                return false; // 阻止默认 form 跳转
            });
            // 叫车提交事件
            form.on('submit(demo2)', function (data) {
                var field = data.field; // 获取表单字段值
                console.log("field.WeightInput:"+field.WeightInput);
                if(field.WeightInput.length != 0)
                {
                    a = parseFloat(field.WeightInput);
                }
                var param = {
                    AreaNo: field.AreaSelect2,
                    LocateNo : field.LocateSelect2,
                    PlnStatus:field.PalletStatus2,
                    SkuNo:field.SkuSelect2,
                    LotNo:field.LotNoInput,
                    Weight:parseFloat(field.WeightInput)
                    Weight:a
                };
                console.log(param);
                sendData(IP + "/DownApi/jiaoCheHopper", param, 'post', function(res) {
                    if (res.code == 0) { //成功
                        layer.msg(res.msg, {
HTML/views/StatisticalReport/BoxInfor.html
@@ -219,9 +219,9 @@
                            if(d.PalletStatus=='0'){ 
                                html = `净桶`; 
                            } else if(d.PalletStatus=='1') { 
                                html = `预混`;
                                html = `清洗中`;
                            } else if(d.PalletStatus=='2') { 
                                html = `半成品`;
                                html = `满桶`;
                            }else if(d.PalletStatus=='3') { 
                                html = `脏桶`; 
                            }
@@ -348,7 +348,7 @@
                    {field: 'LotText', title: '批次描述', align: 'center'},
                    //{field: 'SupplierLot', title: '供货批次', align: 'center'},
                    {field: 'Status', title: '分配状态', align: 'center', templet: '#TempletStatus'},
                    {field: 'Qty', title: '数量', align: 'center'},
                    {field: 'Qty', title: '重量(KG)', align: 'center'},
                    {field: 'LockQty', title: '锁定数量', align: 'center',},
                    {field: 'FrozenQty', title: '冻结数量', align: 'center'},
                    {field: 'InspectStatus', title: '质检状态', align: 'center', templet: '#InspectStatus1'}, 
Wms/Model/InterFaceModel/HttpModel.cs
@@ -788,20 +788,31 @@
        /// 是否必填:是
        /// </summary>
        public string Message { get; set; }
    public Data data { get; set; }
        /// <summary>
        /// 请求编号
        /// 是否必填:是
        /// </summary>
        public string ReqCode { get; set; }
        public string ErrorCode { get; set; }
        /// <summary>
        /// 返回的数据结构
        /// 是否必填:否
        /// 请求编号
        /// 是否必填:是
        /// </summary>
        public string Data { get; set; }
        public bool success { get; set; }
    }
public class AgvTaskBindBack
{
    public string code { get; set; }
    public string message { get; set; }
    public bool success { get; set; }
}
    /// <summary>
    /// AGV申请空托盘垛入库
    /// </summary>
Wms/Utility/Tools/RcsHelper.cs
@@ -25,7 +25,24 @@
        public static bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null)
        {
            bool result = false;
            var tasktype = "F12";
            var tasktype = "";
            switch (taskDetial.Crtype)
            {
                case "1":  //叫桶
                    tasktype = "F12";
                    break;
                case "2":  //叫车
                    tasktype = "F12";
                    break;
                case "3":  //清洗机叫脏桶
                    tasktype = "F20";
                    break;
                case "4":  //清洗机取净桶
                    tasktype = "F21";
                    break;
                default:
                    break;
            }
            //跨楼层任务tasktype值赋值……
            //tasktype = "";
@@ -50,6 +67,8 @@
            AgvCreateTaskModel taskModel = new AgvCreateTaskModel();
            taskModel.taskType = tasktype;
            taskModel.targetRoute = pahtList;
            taskModel.initPriority = 100;
            taskModel.robotTaskCode = taskDetial.Taskno;
            //AGV任务下发时增加hearder:X-LR-REQUEST-ID,值为随机数
            long ran = DateTime.Now.Ticks;
@@ -61,7 +80,7 @@
            string response = HttpHelper.DoPost(url, jsonData, "下发给AGV转运命令", "AGV", key);
            //解析返回数据 
            var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response);
            if (agvModel.Code == "0")
            if (agvModel.Code == "SUCCESS")
            {
                result = true;//给下车下发任务成功
@@ -102,8 +121,8 @@
            var jsonData = JsonConvert.SerializeObject(carrierInfo);
            string response = HttpHelper.DoPost(url, jsonData, "下发给AGV绑定载具命令", "AGV", key);
            //解析返回数据 
            var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response);
            if (agvModel.Code == "0")
            var agvModel = JsonConvert.DeserializeObject<AgvTaskBindBack>(response);
            if (agvModel.code == "SUCCESS")
            {
                result = true;//给下车下发任务成功
@@ -112,9 +131,9 @@
            else
            {
                var logStr = $@".\log\AGV\下发给AGV绑定载具命令" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                LogFile.SaveLogToFile($"下发给AGV绑定载具命令异常:( {agvModel.Message} ),", logStr);
                LogFile.SaveLogToFile($"下发给AGV绑定载具命令异常:( {agvModel.message} ),", logStr);
                agvMsg = agvModel.Message;
                agvMsg = agvModel.message;
            }
            return result;
Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -297,17 +297,19 @@
                var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne)).Select(s => s.LocatNo);
                //先找不需要移库的桶
                var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
                var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault();
                if (palletModel == null)
                {
                    //找需要移库的桶
                    palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
                    palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault();
                    if (palletModel == null)
                    {
                        throw new Exception("未找到对应桶信息");
                    }
                    resultYi = YikuTask(palletModel.PalletNo, taskNo, url,bindUrl);
                }
                palletModel.Status = "2";
                Db.Updateable(palletModel).ExecuteCommand();
                #endregion
                //起始储位地址信息
                var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
@@ -328,9 +330,9 @@
                    Receiver = "RCS",
                    IsSuccess = 0, //是否下发成功 0失败 1成功
                    StartLocat = "",//起始位置
                    StartLocat = startLoction.LocatNo,//起始位置
                    EndLocat = endLocate,//目标位置
                    PalletNo = "",//托盘码
                    PalletNo = palletModel.PalletNo,//托盘码
                    IsSend = 1,//是否可再次下发
                    IsCancel = 1,//是否可取消
                    IsFinish = 1,//是否可完成
@@ -359,7 +361,7 @@
                    //给下车下发任务
                    logTaskEntry.SendDate = DateTime.Now;//发送时间
                    //下发载具类型
                    var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, url, out string agvBindMsg);
                    var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, bindUrl, out string agvBindMsg);
                    if (bind)
                    {
                        var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
@@ -371,7 +373,7 @@
                            //logTaskEntry.IsCancel = 0;
                            logTaskEntry.BackDate = DateTime.Now;
                            logTaskEntry.Status = "1";//正在执行
                            Db.Insertable(logTaskEntry).ExecuteCommand();
                            Db.Updateable(logTaskEntry).ExecuteCommand();
                            startLoction.Status = "3";//出库中
                            Db.Updateable(startLoction).ExecuteCommand();
@@ -383,14 +385,14 @@
                        {
                            logTaskEntry.IsSuccess = 0;
                            logTaskEntry.Information = agvMsg;
                            Db.Insertable(logTaskEntry).ExecuteCommand();
                            Db.Updateable(logTaskEntry).ExecuteCommand();
                        }
                    }
                    else 
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = "货架与货位绑定失败,原因:"+agvBindMsg;
                        Db.Insertable(logTaskEntry).ExecuteCommand();
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                    }
                   
                }
@@ -442,11 +444,12 @@
                Db.BeginTran();
                //桶信息
                var pln = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == plnNo);
                var pln = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == StartLocate && w.AreaNo == areaNo);
                if (pln == null)
                {
                    throw new Exception("未查询到桶信息");
                }
                plnNo = pln.PalletNo;
                //起始储位信息
                var startLoction = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.AreaNo == areaNo && m.LocatNo == StartLocate);
@@ -461,10 +464,6 @@
                        throw new Exception("没有查询到物料信息");
                    }
                    skuName = sku.SkuName;
                }
                else if (plnStatus == "3")
                {
                }
                //目标楼层
                var layer = startLoction.Layer;
@@ -502,7 +501,7 @@
                        CompleteTime = DateTime.Now,
                        PalletStatus = plnStatus,
                        Status = "0",
                        Status = "2",
                        InspectMark = "0",
                        BitPalletMark = "0",
                        InspectStatus = "1",
@@ -513,13 +512,15 @@
                {
                    stockDetail.PalletStatus = plnStatus;
                    stockDetail.SkuNo = skuNo;
                    stockDetail.SkuName = skuName;
                    stockDetail.LotNo = lotNo;
                    stockDetail.Qty = weight;
                    stockDetail.Status = "2";
                    Db.Updateable(stockDetail).ExecuteCommand();
                }
                //分配储位
                var endLocatInfo = GetLocatModel(house.WareHouseNo, plnStatus, skuNo, pln.Standard);//目标储位
                var endLocatInfo = GetLocatModel(house.WareHouseNo, plnStatus, startLoction.WareHouseNo, skuNo, pln.Standard,lotNo);//目标储位
                //没有可用空储位
                if (endLocatInfo == null)
                {
@@ -575,7 +576,7 @@
                        //logTaskEntry.IsCancel = 0;
                        logTaskEntry.BackDate = DateTime.Now;
                        logTaskEntry.Status = "1";//正在执行
                        Db.Insertable(logTaskEntry).ExecuteCommand();
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                        startLoction.Status = "3";//出库中
                        Db.Updateable(startLoction).ExecuteCommand();
@@ -634,10 +635,10 @@
                {
                    throw new Exception($"任务号为:{taskNo}的任务不存在!");
                }
                if (taskInfo.Status != "1" && comeFrom != "WMS")
                {
                    throw new Exception($"任务号为:{taskNo}的任务状态异常");
                }
                //if (taskInfo.Status != "0" && comeFrom != "WMS")
                //{
                //    throw new Exception($"任务号为:{taskNo}的任务状态异常");
                //}
                #endregion
                //开启事务
                Db.BeginTran();
@@ -680,6 +681,7 @@
                    throw new Exception($"目标储位信息不存在");
                }
                endLocatInfo.Status = "1";//有物品
                endLocatInfo.UpdateTime = DateTime.Now;//更新时间
                //修改目标储位状态
                Db.Updateable(endLocatInfo).ExecuteCommand();
@@ -702,7 +704,7 @@
                }
                else if (endAreaInfo.Type == "1")//满桶区
                {
                    stockDetail.PalletStatus = "1";
                    stockDetail.PalletStatus = "2";
                    stockDetail.Status = "0";//待分配
                }
                else if (endAreaInfo.Type == "2")//脏桶区
@@ -764,6 +766,38 @@
                {
                    throw new Exception("非叫料状态");
                }
                switch (deviceStation)
                {
                    case "input"://叫脏桶
                        switch (deviceID)
                        {
                            case "2001":
                                deviceID = "1001";
                                break;
                            case "2002":
                                deviceID = "1003";
                                break;
                            default:
                                throw new Exception("叫脏桶点位异常");
                        }
                        break;
                    case "output"://叫车拉净桶
                        switch (deviceID)
                        {
                            case "2001":
                                deviceID = "1002";
                                break;
                            case "2002":
                                deviceID = "1004";
                                break;
                            default:
                                throw new Exception("叫净桶点位异常");
                        }
                        break;
                    default:
                        throw new Exception("叫料类型异常");
                }
                //通过设备号查找到所属设备(区域)
                var deviceInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == deviceID);
                if (deviceInfo == null)
@@ -775,6 +809,7 @@
                var startLoction = new SysStorageLocat();//起始储位信息
                var endLoction = new SysStorageLocat();//目标储位信息
                var palletModel = new DataStockDetail();//分配桶信息
                string type = "";//叫料类型
                //开启事务
                Db.BeginTran();
@@ -783,64 +818,117 @@
                switch (deviceStation)
                {
                    case "input"://叫脏桶
                        //叫桶设备所在储位信息(目标储位)
                        endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                        if (deviceID == "1001" || deviceID == "1003")
                        {
                            type = "3";
                            //叫桶设备所在储位信息(目标储位)
                            endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                        // 所有待分配的脏桶
                        var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0" && w.PalletStatus == "3");
                        //优先查找脏桶缓存车间
                        palletModel = stockDetail.Where(w => w.AreaNo == "C43").OrderByDescending(o => o.UpdateTime).First();
                        if (palletModel == null)//脏桶缓存车间没有脏桶,再从三楼中间站脏桶区查找
                        {
                            palletModel = stockDetail.Where(w =>w.WareHouseNo=="M16" && w.AreaNo == "C26").OrderByDescending(o => o.UpdateTime).First();
                            // 所有待分配的脏桶
                            var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0" && w.PalletStatus == "3").OrderByDescending(w => w.UpdateTime).ToList();
                            //判断当前清洗机设备上有几个脏桶,status:2 正在清洗的脏桶(状态触发变更为AGV叫第2个脏桶时触发)
                            int ztQty = Db.Queryable<DataStockDetail>().Count(w => w.IsDel == "0" && w.Status == "2" && w.LocatNo == deviceID);
                            if (ztQty == 1)
                            {
                                throw new Exception((deviceID == "1001"?"1":"2") + "号清洗机脏桶已满,重复叫料!");
                            }
                            //先查看叫料设备位是否有脏桶
                            if (endLoction.Status == "1")
                            {
                                //有脏桶的话,将更改此桶状态(代表此桶正在清洗中)
                                var qxStock = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == endLoction.LocatNo).First();
                                qxStock.Status = "2";
                                qxStock.UpdateTime = DateTime.Now;//清洗时间
                                Db.Updateable(qxStock).ExecuteCommand();
                                //更改设备储位状态为空储位
                                endLoction.Status = "0";
                                Db.Updateable(endLoction).ExecuteCommand();
                            }
                            //优先查找脏桶缓存车间
                            palletModel = stockDetail.Where(w => w.AreaNo == "C54").FirstOrDefault();
                            if (palletModel == null)//脏桶缓存车间没有脏桶,再从三楼中间站脏桶区查找
                            {
                                palletModel = stockDetail.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C26").FirstOrDefault();
                            }
                            if (palletModel == null)//三楼中间站脏桶区没有脏桶,再从四楼中间站脏桶区查找
                            {
                                palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").FirstOrDefault();
                            }
                            if (palletModel == null)
                            {
                                throw new Exception("无脏桶可分配");
                            }
                            //起始储位地址信息
                            startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
                            if (startLoction == null)
                            {
                                throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}");
                            }
                        }
                        if (palletModel == null)//三楼中间站脏桶区没有脏桶,再从四楼中间站脏桶区查找
                        else
                        {
                            palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").OrderByDescending(o => o.UpdateTime).First();
                        }
                        if (palletModel == null)
                        {
                            throw new Exception("无脏桶可分配");
                        }
                        //起始储位地址信息
                        startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
                        if (startLoction == null)
                        {
                            throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}");
                            throw new Exception("起始目标储位信息不存在");
                        }
                        break;
                    case "output"://净桶申请储位
                        //叫桶设备所在储位信息(起始储位)
                        startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                        //桶信息
                        palletModel = Db.Queryable<DataStockDetail>().Where(w => w.WareHouseNo==houseNo && w.AreaNo==deviceInfo.AreaNo && w.LocatNo==startLoction.LocatNo).First();
                        if (palletModel == null)
                        if (deviceID == "1002" || deviceID == "1004")
                        {
                            throw new Exception("未查询到净桶信息");
                            type = "4";
                            //叫桶设备所在储位信息(起始储位)
                            startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
                            //获取清洗机上第一次叫的脏桶
                            string locate = deviceID == "1002"?"1001":"1003";
                            palletModel = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == locate && (w.Status == "2" || w.Status == "0")).OrderBy(o => o.CreateTime).First();
                            if (palletModel == null)
                            {
                                throw new Exception("未找到库存中正在清洗的脏桶");
                            }
                            if (!string.IsNullOrEmpty(palletModel.LocatNo))
                            {
                                palletModel.LocatNo = startLoction.LocatNo;
                                palletModel.PalletStatus = "0";
                                palletModel.Status = "0";
                                Db.Updateable(palletModel).ExecuteCommand();
                            }
                            //分配储位
                            //查找所有净桶储位
                            var jtLocate = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0")
                                                .OrderBy(w => w.Row).OrderByDescending(w => w.Column).ToList();
                            if (jtLocate.Count == 0)
                            {
                                throw new Exception("没有空余的净桶储位");
                            }
                            //优先分配四楼中间站净桶区
                            //endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01")
                            //                    .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            //if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找
                            //{
                            endLoction = jtLocate.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C24")
                                                .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            //}
                            if (endLoction == null)//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找             PS:小车现在还不支持清洗机直接送往4楼净桶区
                            {
                                endLoction = jtLocate.Where(w => w.WareHouseNo == "M44" && w.AreaNo == "C55")
                                                .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            }
                            if (endLoction == null)
                            {
                                throw new Exception("未查询到合适储位");
                            }
                            //string startlono = startLoction.LocatNo == "1001" ? "1002" : "1004";//清洗完成点位
                            //startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == startlono);
                            //if (startLoction == null)
                            //{
                            //    throw new Exception("未找到清洗起始点位");
                            //}
                        }
                        //分配储位
                        //优先分配四楼中间站净桶区
                        endLoction= Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                            && w.WareHouseNo == "M01" && w.AreaNo == "C01")
                                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找
                        else
                        {
                            endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                            && w.WareHouseNo == "M16" && w.AreaNo == "C24")
                                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        }
                        if (endLoction == null)//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找
                        {
                            endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                            && w.WareHouseNo == "M44" && w.AreaNo == "C55")
                                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        }
                        if (endLoction == null)
                        {
                            throw new Exception("未查询到合适储位");
                            throw new Exception("起始目标储位信息不存在");
                        }
                        break;
@@ -848,6 +936,7 @@
                        throw new Exception("叫料点位异常");
     
                }
                var taskNo = new Common().GetMaxNo("TK");
                //添加任务
                var logTaskEntry = new LogTask
@@ -857,9 +946,9 @@
                    Receiver = "RCS",
                    IsSuccess = 0, //是否下发成功 0失败 1成功
                    StartLocat = "",//起始位置
                    StartLocat = startLoction.LocatNo,//起始位置
                    EndLocat = endLoction.LocatNo,//目标位置
                    PalletNo = "",//托盘码
                    PalletNo = palletModel.PalletNo,//托盘码
                    IsSend = 1,//是否可再次下发
                    IsCancel = 1,//是否可取消
                    IsFinish = 1,//是否可完成
@@ -878,7 +967,7 @@
                    Startport = palletModel.LocatNo,//起始位置
                    Endport = endLoction.LocatNo,//目标位置
                    Pallno = palletModel.PalletNo,//桶号
                    Crtype = "1",//叫桶
                    Crtype = type,//叫桶
                };
                string agvMsg = string.Empty;
@@ -897,7 +986,7 @@
                        //logTaskEntry.IsCancel = 0;
                        logTaskEntry.BackDate = DateTime.Now;
                        logTaskEntry.Status = "1";//正在执行
                        Db.Insertable(logTaskEntry).ExecuteCommand();
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                        startLoction.Status = "3";//出库中
                        Db.Updateable(startLoction).ExecuteCommand();
@@ -909,14 +998,14 @@
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = agvMsg;
                        Db.Insertable(logTaskEntry).ExecuteCommand();
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                    }
                }
                else
                {
                    logTaskEntry.IsSuccess = 0;
                    logTaskEntry.Information = agvBindMsg;
                    Db.Insertable(logTaskEntry).ExecuteCommand();
                    Db.Updateable(logTaskEntry).ExecuteCommand();
                }
                
                //提交事务
@@ -934,6 +1023,7 @@
        {
            try
            {
                bool t = false;
                //分配桶的库存信息
                var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
                if (palletInfo == null)
@@ -1022,7 +1112,7 @@
                        string agvMsg = string.Empty;
                        //给下车下发任务
                        logTaskEntry.SendDate = DateTime.Now;//发送时间
                                                             //下发载具与货位绑定
                        //下发载具与货位绑定
                        var bind = RcsHelper.BindPalletAndSite(palletInfoYi.LocatNo, palletInfoYi.PalletNo, bindUrl, out string agvBindMsg);
                        if (bind)
                        {
@@ -1062,10 +1152,15 @@
                            throw new Exception($"给小车下发移库任务失败,桶号:{palletInfoYi.PalletNo}");
                        }
                        t = true;
                    }
                    else
                    {
                        return t;
                    }
                }
                return true;
                return t;
            }
            catch (Exception e)
            {
@@ -1086,7 +1181,7 @@
                Db.BeginTran();
                //查找任务信息
                var logTaskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.TaskNo == taskNo);
                var logTaskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "0" && w.TaskNo == taskNo);
                if (logTaskInfo == null)
                {
                    throw new Exception("未查询到该任务");
@@ -1173,6 +1268,7 @@
                    }
                    
                }
                Db.CommitTran();
            }
            catch (Exception e)
            {
@@ -1220,7 +1316,7 @@
                            continue;
                        }
                        //分配储位
                        var endLocatInfo = GetLocatModel(itemHouseNo,detailInfo.PalletStatus,detailInfo.SkuNo,detailInfo.Standard);//目标储位
                        var endLocatInfo = GetLocatModel(itemHouseNo,detailInfo.PalletStatus,"",detailInfo.SkuNo,detailInfo.Standard,detailInfo.LotNo);//目标储位
                        //没有可用空储位
                        if (endLocatInfo == null)
                        {
@@ -1260,7 +1356,7 @@
                            Crtype = "2"//叫桶
                        };
                        string agvMsg = string.Empty;
                        //给下车下发任务
                        //给下车下发任务            s
                        logTaskEntry.SendDate = DateTime.Now;//发送时间
                        //下发载具与货位绑定
                        var bind = RcsHelper.BindPalletAndSite(detailInfo.PalletNo, detailInfo.LocatNo, bindUrl, out string agvBindMsg);
@@ -1325,7 +1421,7 @@
        /// <param name="standard">桶规格</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        private SysStorageLocat GetLocatModel(string houseNo, string palletStatus,string skuNo="",string standard="")
        private SysStorageLocat GetLocatModel(string houseNo, string palletStatus,string zonghong,string skuNo="",string standard="",string lotNo = "")
        {
            try
            {
@@ -1342,44 +1438,88 @@
                                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        break;
                    case "2"://满桶
                             //查到到满桶区域编号
                        areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First();
                        //分配储位
                        //先查到同物料的组
                        string sql = $@"select Row from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and LocatNo in(
                                                select LocatNo from DataStockDetail where SkuNo='{skuNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}'
                                            ) group by Row";
                        List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
                        foreach (var rowItem in RowList)
                        //总混分配储位 (仓库编码M12,M13),分配逻辑:优先分配同物料的组,再分配到3楼中间站,最后分配到4楼中间站
                        if (zonghong == "M12" || zonghong == "M13")
                        {
                            endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                           && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem)
                                           .OrderByDescending(o => o.Column).First();
                            //先查到同物料的组
                            string sql = $@"select Row from SysStorageLocat where LocatNo in(
                                                    select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}'
                                                    and AreaNo in ('C02','C25')
                                                ) group by Row";
                            if (endLocatInfo != null)
                            List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
                            foreach (var rowItem in RowList)
                            {
                                break;
                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.Row == rowItem)
                                               .OrderByDescending(o => o.Column).First();
                                if (endLocatInfo.LocatNo != null)
                                {
                                    break;
                                }
                            }
                            //没有找到相同物料同组的空储位
                            if (endLocatInfo.LocatNo == null)
                            {
                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                                && (w.AreaNo == "C02" || w.AreaNo == "C25"))
                                               .OrderBy(o=>o.Layer).OrderByDescending(o => o.Column).OrderBy(o => o.Row).First();
                            }
                        }
                        else {//其他区域
                            //查到到满桶区域编号
                            areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First();
                            //分配储位
                            //先查到同物料的组
                            string sql = $@"select Row from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '0' and LocatNo in(
                                                    select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}'
                                                ) group by Row";
                            List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
                            foreach (var rowItem in RowList)
                            {
                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                               && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem)
                                               .OrderByDescending(o => o.Column).First();
                                if (endLocatInfo.LocatNo != null)
                                {
                                    break;
                                }
                            }
                            //没有找到相同物料同组的空储位
                            if (endLocatInfo.LocatNo == null)
                            {
                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                               && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
                                               .OrderByDescending(o => o.Column).OrderBy(o => o.Row).First();
                            }
                        }
                        //没有找到相同物料同组的空储位
                        if (endLocatInfo == null)
                        {
                            endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                           && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
                                           .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        }
                        break;
                    case "3"://脏桶
                             //查到到脏桶区域编号
                        areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "2").Select(s => s.AreaNo).First();
                        //查到到脏桶区域编号,存放顺序,C54 料斗清洗暂存间,C26 3楼中间站脏桶区,C03 4楼中间站脏桶区
                        var ztAreaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Type == "2").Select(w => w.AreaNo).ToList();
                        //查找所有可用脏桶库位
                        var ztLocat = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && ztAreaNo.Contains(w.AreaNo))
                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).ToList();
                        //areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "2").Select(s => s.AreaNo).First();
                        //分配储位
                        endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
                                            && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
                                            .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
                        //料斗清洗暂存间
                        endLocatInfo = ztLocat.Where(w => w.AreaNo == "C54").FirstOrDefault();
                        if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
                        {
                            endLocatInfo = ztLocat.Where(w => w.AreaNo == "C26").FirstOrDefault();
                            if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
                            {
                                endLocatInfo = ztLocat.Where(w => w.AreaNo == "C03").FirstOrDefault();
                                if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
                                {
                                    throw new Exception("无可用脏桶库位");
                                }
                            }
                        }
                        break;
                }
                return endLocatInfo;
Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -7,6 +7,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
@@ -941,17 +943,12 @@
                    stockDetail.PalletStatus = "0";
                    stockDetail.Status = "0";//待分配
                }
                else if (endAreaInfo.Type == "1")//预混区
                {
                    stockDetail.PalletStatus = "1";
                    stockDetail.Status = "0";//待分配
                }
                else if (endAreaInfo.Type == "2")//半成品区
                else if (endAreaInfo.Type == "1")//满桶
                {
                    stockDetail.PalletStatus = "2";
                    stockDetail.Status = "0";//待分配
                }
                else if (endAreaInfo.Type == "3")//脏桶区
                else if (endAreaInfo.Type == "2")//脏桶区
                {
                    stockDetail.PalletStatus = "3";
                    stockDetail.LotNo = "";//批次
@@ -1097,18 +1094,16 @@
                }
                locatEnd.Status = "0"; //空储位
                Db.Updateable(locatEnd).ExecuteCommand();
                if (task.Type == "1")//出库任务
                //修改库存明细
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == task.PalletNo);
                if (stockDetail == null)
                {
                    //修改库存明细
                    var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == task.PalletNo && w.Status == "2");
                    if (stockDetail == null)
                    {
                        throw new Exception("未查询到该桶库存信息,请检查!");
                    }
                    stockDetail.Status = "0";//待分配
                    Db.Updateable(stockDetail).ExecuteCommand();
                    throw new Exception("未查询到该桶库存信息,请检查!");
                }
                stockDetail.Status = "0";//待分配
                Db.Updateable(stockDetail).ExecuteCommand();
                //添加操作日志记录
                var k = new OperationCrServer().AddLogOperationCr("库内作业", "库内日志", taskNo, "取消", $"点击取消按钮、取消了任务号为:{taskNo}的任务", userId);
                Db.CommitTran();
@@ -1125,7 +1120,7 @@
        /// <param name="taskNo"></param>
        /// <param name="userId"></param>
        /// <exception cref="Exception"></exception>
        public void DownTask(string taskNo, int userId,string url)
        public void DownTask(string taskNo, int userId,string url,string bindUrl)
        {
            try
            {
@@ -1142,7 +1137,7 @@
                    throw new Exception("只有等待执行的任务才可手动下发");
                }
                //查找该桶有没有正在执行的任务
                var tasking = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.PalletNo == logTaskEntry.PalletNo);
                var tasking = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1"  && w.PalletNo == logTaskEntry.PalletNo);
                if (tasking != null)
                {
                    throw new Exception($"该桶有正在执行的任务");
@@ -1153,20 +1148,20 @@
                {
                    throw new Exception($"未查询到起始储位信息");
                }
                if (startLocatInfo.Status != "1")
                {
                    throw new Exception($"起始储位状态异常");
                }
                //if (startLocatInfo.Status != "1")
                //{
                //    throw new Exception($"起始储位状态异常");
                //}
                //目标储位信息
                var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == logTaskEntry.EndLocat);
                if (endLocatInfo == null)
                {
                    throw new Exception($"未查询到目标储位信息");
                }
                if (endLocatInfo.Status != "0")
                {
                    throw new Exception($"目标储位状态异常");
                }
                //if (endLocatInfo.Status != "0")
                //{
                //    throw new Exception($"目标储位状态异常");
                //}
                //组织给小车下发任务信息
                var task = new TaskDetial
                {
@@ -1179,30 +1174,33 @@
                string agvMsg = string.Empty;
                //给下车下发任务
                logTaskEntry.SendDate = DateTime.Now;//发送时间
                var agvResult = CreateTaskForAgv(task, url, out agvMsg);
                if (agvResult)//成功
                //先给货位绑定载具
                var bind = RcsHelper.BindPalletAndSite(logTaskEntry.PalletNo, logTaskEntry.StartLocat, bindUrl, out string agvBindMsg);
                if (bind)
                {
                    //请求成功修改任务表相应字段状态
                    logTaskEntry.IsSuccess = 1;
                    logTaskEntry.IsSend = 0;
                    logTaskEntry.IsCancel = 0;
                    logTaskEntry.BackDate = DateTime.Now;
                    logTaskEntry.Status = "1";//正在执行
                    Db.Insertable(logTaskEntry).ExecuteCommand();
                    var agvResult = CreateTaskForAgv(task, url, out agvMsg);
                    if (agvResult)//成功
                    {
                        //请求成功修改任务表相应字段状态
                        logTaskEntry.IsSuccess = 1;
                        logTaskEntry.IsSend = 1;
                        logTaskEntry.IsCancel = 1;
                        logTaskEntry.BackDate = DateTime.Now;
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                    startLocatInfo.Status = "3";//出库中
                    Db.Updateable(startLocatInfo).ExecuteCommand();
                        startLocatInfo.Status = "3";//出库中
                        Db.Updateable(startLocatInfo).ExecuteCommand();
                    endLocatInfo.Status = "2";//入库中
                    Db.Updateable(endLocatInfo).ExecuteCommand();
                        endLocatInfo.Status = "2";//入库中
                        Db.Updateable(endLocatInfo).ExecuteCommand();
                    }
                    else//失败
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = agvMsg;
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                    }
                }
                else//失败
                {
                    logTaskEntry.IsSuccess = 0;
                    logTaskEntry.Information = agvMsg;
                    Db.Insertable(logTaskEntry).ExecuteCommand();
                }
                //添加操作日志记录
                var k = new OperationCrServer().AddLogOperationCr("库内作业", "库内日志", taskNo, "下发", $"点击下发按钮、任务号为:{taskNo}的任务", userId);
                Db.CommitTran();
Wms/WMS.BLL/SysServer/PalletsServer.cs
@@ -254,6 +254,7 @@
                //更新储位状态
                locatModel.Status = "1";//有物品
                locatModel.UpdateTime = DateTime.Now;
                db.Updateable(locatModel).ExecuteCommand();
                //下发AGV绑定载具接口
Wms/WMS.DAL/Common.cs
@@ -232,9 +232,9 @@
                    var list = DataContext.Db.Queryable<BllStockCheck>().Where(m => m.CRNo.StartsWith("CR")).ToList();
                    orderNo = list.Select(a => a.CRNo).Max();
                }
                else if (codeFlag == InOutFlag.TN.ToString())//任务
                else if (codeFlag == InOutFlag.TK.ToString())//任务
                {
                    var list = DataContext.Db.Queryable<LogTask>().Where(m => m.TaskNo.StartsWith("TN")).ToList();
                    var list = DataContext.Db.Queryable<LogTask>().Where(m => m.TaskNo.StartsWith("TK")).ToList();
                    orderNo = list.Max(m=>m.TaskNo);
                }
                else if (codeFlag == InOutFlag.EX.ToString())//异常
@@ -478,7 +478,7 @@
        /// 任务
        /// </summary>
        [Description("任务")]
        TN,
        TK,
        /// <summary>
        /// 异常号 
Wms/WMS.Entity/DataEntity/DataStockDetail.cs
@@ -209,7 +209,7 @@
        /// <summary>
        /// 托盘状态
        /// Default:0:净桶 1:预混 2:半成品 3:脏桶
        /// Default:0:净桶 1:清洗中 2:满桶 3:脏桶
        /// </summary>
        public string PalletStatus { get; set; }
Wms/WMS.IBLL/IBllTransServer/IRcsServer.cs
@@ -57,6 +57,6 @@
        /// <param name="taskNo"></param>
        /// <param name="userId"></param>
        /// <exception cref="Exception"></exception>
        void DownTask(string taskNo, int userId, string url);
        void DownTask(string taskNo, int userId, string url,string bindurl);
    }
}
Wms/Wms/Controllers/DownApiController.cs
@@ -912,9 +912,10 @@
                //具体处理方法
                _hopper.OutBinAgv(model.robotTaskCode, _config.AgvHost + _config.GenAgvSchedulingTask,_config.AgvHost+_config.AGVBindPallets);
                resultModel.code = "0";
                resultModel.message = "成功";
                resultModel.da.robotTaskCode = model.robotTaskCode;
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "0", message = "成功", da =data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
@@ -923,10 +924,10 @@
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-异常:( {ex.Message} ),", logStr);
                resultModel.code = "1";
                resultModel.message = ex.Message;
                resultModel.da.robotTaskCode = model.robotTaskCode;
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "1", message = ex.Message, da = data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
@@ -957,9 +958,9 @@
                //具体处理方法
                _hopper.RCSFinishTask(model.robotTaskCode, "1", "AGV");
                resultModel.code = "0";
                resultModel.message = "成功";
                resultModel.da.robotTaskCode = model.robotTaskCode;
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "0", message = "成功", da = data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-返回报文:( {jsonData2} ),", logStr);
@@ -969,9 +970,9 @@
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-异常:( {ex.Message} ),", logStr);
                resultModel.code = "1";
                resultModel.message = ex.Message;
                resultModel.da.robotTaskCode = model.robotTaskCode;
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "1", message = ex.Message, da = data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
@@ -1015,7 +1016,51 @@
                LogFile.SaveLogToFile($"AGV任务执行通知-任务单取消-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
        }
        /// <summary>
        /// 走出储位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AGVCallback(AgvTaskDto model)
        {
            //记录log
            var logStr = $@".\log\AGV\任务执行通知" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel2 resultModel = null;//返回信息
            try
            {
                var extraValue = new ExtraModel();
                extraValue = model.extra;
                switch (extraValue.values.method)
                {
                    case "outbin":
                        var a = outbin(model);
                        break;
                    case "end":
                        var b = end(model);
                        break;
                    default:
                        break;
                }
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "0", message = "成功", da = data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception ex)
            {
                Data data = new Data();
                data.robotTaskCode = model.robotTaskCode;
                resultModel = new AgvResultModel2 { code = "1", message = ex.Message, da = data };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
        #endregion
@@ -1072,7 +1117,7 @@
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _rcsserver.DownTask(model.taskNo, int.Parse(userId), _config.AgvHost + _config.GenAgvSchedulingTask);
                _rcsserver.DownTask(model.taskNo, int.Parse(userId), _config.AgvHost + _config.GenAgvSchedulingTask,_config.AgvHost + _config.AGVBindPallets);
                return Ok(new { code = 0, msg = "重新下发已完成", data = "" });
            }
@@ -1106,7 +1151,7 @@
                //具体处理方法
                _rcsserver.RCSFinishTask(model.taskNo, "1", "WMS");
                return Ok(new { code = 0, msg = "重新下发已完成", data = "" });
                return Ok(new { code = 0, msg = "任务已手动完成", data = "" });
            }
            catch (Exception e)
            {
@@ -1373,6 +1418,8 @@
                return Ok(resultModel);
            }
        }
        #endregion
    }
Wms/Wms/Properties/launchSettings.json
@@ -21,8 +21,8 @@
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://192.168.10.201",
      "sslPort": 44363
      "applicationUrl": "http://localhost:58787/",
      "sslPort": 44323
    }
  }
}
Wms/Wms/appsettings.json
@@ -12,8 +12,8 @@
    //"ConnectionString": "Server=47.95.120.53;Database=WMS_JC09;User ID=sa;Password=boxline!@#;Integrated Security=False;",
    //"ConnectionString": "Server=192.168.62.106;Database=WMS_JC24;User ID=sa;Password=sql2019;Integrated Security=False;",
    //"ConnectionString": "Server=192.168.62.200;Database=WMS_JC37;User ID=sa;Password=sql2019;Integrated Security=False;"
    "ConnectionString": "Server=.;Database=WMS_JC37;User ID=sa;Password=sa@123456;Integrated Security=False;"
    //"ConnectionString": "Data Source=DESKTOP-0EJDG95\\MSSQLSERVER1;Initial Catalog=WMS_V01;Integrated Security=True;"
    //"ConnectionString": "Server=.;Database=WMS_JC37;User ID=sa;Password=sa@123456;Integrated Security=False;"
    "ConnectionString": "Data Source=192.168.10.201\\WMSSQLSERVER;Database=WMS_JC37;User ID=sa;Password=sa@123456;Integrated Security=False;"
    //"ConnectionString": "Server=.\\MSSQLSERVER2019;Database=WMS_JC23-2;User Id=sa;Password=admin2023@;" // SqlServer 库连接字符串
    //"ConnectionString": "Server=172.16.105.10;Database=WMS_JC23-2;User ID=sa;Password=sql2019;Integrated Security=False;"
    //"ConnectionString": "Server=172.16.105.2;Database=WMS_JC23-2;User ID=sa;Password=boxline@2024;Integrated Security=False;"