1.报工增加按序和不按序报工操作,工序调整增加按序和不按序报工调整
2.增加SOP管理:设备SOP管理、工艺SOP管理功能
已添加3个文件
已修改18个文件
1946 ■■■■ 文件已修改
VueWebCoreApi/ApiGroup/OpenApiGroup.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Controllers/GeneralBasicDataController.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Controllers/SopManageMentController.cs 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Controllers/SystemSettingController.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Controllers/WorkOrderController.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/BLL/SopManageMentBLL.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/ProductModelDAL.cs 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/SopManageMentDAL.cs 463 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs 642 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Models/WorkData/WorkList.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Startup.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Tools/ScanStartReport.cs 455 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Tools/TOrganizationRecursion.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/VueWebCoreApi.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/ApiGroup/OpenApiGroup.cs
@@ -45,7 +45,9 @@
        [Description("App智能分析")]
        App智能分析 = 21,
        [Description("App安灯管理")]
        App安灯管理 = 22
        App安灯管理 = 22,
        [Description("SOP管理")]
        SOP管理 = 23
    }
}
VueWebCoreApi/Controllers/GeneralBasicDataController.cs
@@ -183,6 +183,21 @@
        }
        #endregion
        #region[设备类型编码查找设备信息]
        /// <summary>
        /// è®¾å¤‡ç±»åž‹ç¼–码查找设备信息
        /// </summary>
        /// <param name="eqptypecode">设备类型编码</param>
        /// <returns></returns>
        [Route(template: "EqpTypecodeSeachEqpPermissions")]
        [HttpGet]
        public JsonResult EqpTypecodeSeachEqpPermissions(string eqptypecode)
        {
            mes = GeneralBasicDataBLL.EqpTypecodeSeachEqpPermissions(eqptypecode);
            return Json(mes);
        }
        #endregion
        #region[仓库基础资料]
        /// <summary>
        /// ä»“库基础资料
VueWebCoreApi/Controllers/SopManageMentController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,172 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VueWebCoreApi.DLL.BLL;
using VueWebCoreApi.Models;
using VueWebCoreApi.Tools;
namespace VueWebCoreApi.Controllers
{
    [ApiExplorerSettings(GroupName = "SOP管理")]
    [ApiController]
    [Route("api/[controller]")]
    [ChannelActionFilter]
    public class SopManageMentController : Controller
    {
        //定义全局信息返回变量
        ToMessage mes = new ToMessage();
        RedisCommon redis = new RedisCommon();
        #region[系统设置,设备SOP查询]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,设备SOP查询
        /// </summary>
        /// <param name="search">搜索关键字</param>
        /// <param name="check">是否选中最高版本</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "DeviceSopSearch")]
        [HttpGet]
        public JsonResult DeviceSopSearch(string search = null, string check = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = SopManageMentBLL.DeviceSopSearch(search, check, startNum, endNum, prop, order);
            return Json(mes);
        }
        #endregion
        #region[系统设置,设备SOP新增]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,设备SOP新增
        /// </summary>
        /// <param name="eqptypecode">设备类型编码</param>
        /// <param name="device">设备集合字符串</param>
        /// <param name="filename">文件名称</param>
        /// <param name="filetypecode">文件类型编码</param>
        /// <param name="file">上传文件</param>
        /// <returns></returns>
        [Route(template: "DeviceSopAddSeave")]
        [HttpPost]
        public JsonResult DeviceSopAddSeave([FromForm] string eqptypecode, [FromForm] string device, [FromForm] string filename, [FromForm] string filetypecode, IFormFile file)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = SopManageMentBLL.DeviceSopAddSeave(eqptypecode, device, filename, filetypecode, file, us);
            return Json(mes);
        }
        #endregion
        #region[系统设置,设备SOP删除]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,设备SOP删除
        /// </summary>
        /// <param name="id">数据id</param>
        /// <param name="eqpcode">设备编码</param>
        /// <param name="filepath">文件路径</param>
        /// <returns></returns>
        [Route(template: "DeviceSopDeleteSeave")]
        [HttpPost]
        public JsonResult DeviceSopDeleteSeave(string id, string eqpcode, string filepath)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = SopManageMentBLL.DeviceSopDeleteSeave(id, eqpcode, filepath, us);
            return Json(mes);
        }
        #endregion
        #region[系统设置,工艺SOP查询]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,工艺SOP查询
        /// </summary>
        /// <param name="search">搜索关键字</param>
        /// <param name="check">是否选中最高版本</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "ProcessSopSearch")]
        [HttpGet]
        public JsonResult ProcessSopSearch(string search = null, string check = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = SopManageMentBLL.ProcessSopSearch(search, check, startNum, endNum, prop, order);
            return Json(mes);
        }
        #endregion
        #region[系统设置,工艺SOP上传获取最大版本号]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,工艺SOP上传获取最大版本号
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="filetypecode">文件类型编码</param>
        /// <returns></returns>
        [Route(template: "ProcessSopMaxVersion")]
        [HttpGet]
        public JsonResult ProcessSopMaxVersion(string partcode, string routecode, string stepcode,string filetypecode)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = SopManageMentBLL.ProcessSopMaxVersion(partcode, routecode, stepcode,filetypecode,us);
            return Json(mes);
        }
        #endregion
        #region[系统设置,工艺SOP新增]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,工艺SOP新增
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="filename">文件名称</param>
        /// <param name="filetypecode">文件类型编码</param>
        /// <param name="file">上传文件</param>
        /// <param name="version">版本号</param>
        /// <returns></returns>
        [Route(template: "ProcessSopAddSeave")]
        [HttpPost]
        public JsonResult ProcessSopAddSeave([FromForm] string partcode, [FromForm] string routecode, [FromForm] string stepcode, [FromForm] string filename, [FromForm] string filetypecode, [FromForm] string version, IFormFile file)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = SopManageMentBLL.ProcessSopAddSeave(partcode, routecode, stepcode, filename, filetypecode, version, file, us);
            return Json(mes);
        }
        #endregion
        #region[系统设置,工艺SOP删除]
        /// <summary>
        /// ç³»ç»Ÿè®¾ç½®,工艺SOP删除
        /// </summary>
        /// <param name="id">数据id</param>
        /// <param name="partcode">物料编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="filepath">文件路径</param>
        /// <returns></returns>
        [Route(template: "ProcessSopDeleteSeave")]
        [HttpPost]
        public JsonResult ProcessSopDeleteSeave(string id, string partcode,string routecode,string stepcode, string filepath)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = SopManageMentBLL.ProcessSopDeleteSeave(id, partcode, routecode, stepcode, filepath, us);
            return Json(mes);
        }
        #endregion
    }
}
VueWebCoreApi/Controllers/SystemSettingController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -13,7 +14,7 @@
    [ApiExplorerSettings(GroupName = "系统设置")]
    [ApiController]
    [Route("api/[controller]")]
    //[ChannelActionFilter]
    [ChannelActionFilter]
    public class SystemSettingController : Controller
    {
        //定义全局信息返回变量
@@ -179,5 +180,6 @@
            return Json(mes);
        }
        #endregion
    }
}
VueWebCoreApi/Controllers/WorkOrderController.cs
@@ -19,7 +19,7 @@
    [ApiExplorerSettings(GroupName = "工单管理")]
    [ApiController]
    [Route("api/[controller]")]
    [ChannelActionFilter]
    //[ChannelActionFilter]
    public class WorkOrderController : Controller
    {
        //定义全局信息返回变量
@@ -291,15 +291,16 @@
        /// MES工单查找历史引用最新工序信息
        /// </summary>
        /// <param name="wkshopcode">车间编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="partcode">产品编码</param>
        /// <returns></returns>
        [Route(template: "MesOrderNewStepContent")]
        [HttpPost]
        public JsonResult MesOrderNewStepContent(string wkshopcode, string partcode)
        public JsonResult MesOrderNewStepContent(string wkshopcode,string routecode, string partcode)
        {
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = WorkOrderBLL.MesOrderNewStepContent(wkshopcode, partcode, us);
            mes = WorkOrderBLL.MesOrderNewStepContent(wkshopcode, routecode, partcode, us);
            return Json(mes);
        }
        #endregion
@@ -486,7 +487,9 @@
        [HttpGet]
        public JsonResult MesOrderStepStart(string OperType,string SelectType, string wocode, string stepcode )
        {
            mes = WorkOrderBLL.MesOrderStepStart(OperType,SelectType, wocode, stepcode);
            var token = HttpContext.Request.Headers["Token"].ToString();
            User us = JwtTools.Denocode(token.ToString());
            mes = WorkOrderBLL.MesOrderStepStart(OperType,SelectType, wocode, stepcode, us);
            return Json(mes);
        }
        #endregion
VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs
@@ -95,6 +95,13 @@
        }
        #endregion
        #region[设备类型编码查找设备信息]
        public static ToMessage EqpTypecodeSeachEqpPermissions(string eqptypecode)
        {
            return GeneralBasicDataDAL.EqpTypecodeSeachEqpPermissions(eqptypecode);
        }
        #endregion
        #region[仓库基础资料]
        public static ToMessage WareHouse()
        {
VueWebCoreApi/DLL/BLL/SopManageMentBLL.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,66 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VueWebCoreApi.DLL.DAL;
using VueWebCoreApi.Models;
using VueWebCoreApi.Tools;
namespace VueWebCoreApi.DLL.BLL
{
    public class SopManageMentBLL
    {
        #region[系统设置,设备SOP查询]
        public static ToMessage DeviceSopSearch(string search, string check, int startNum, int endNum, string prop, string order)
        {
            return SopManageMentDAL.DeviceSopSearch(search, check, startNum, endNum, prop, order);
        }
        #endregion
        #region[系统设置,设备SOP新增]
        public static ToMessage DeviceSopAddSeave(string eqptypecode, string device, string filename, string filetypecode, IFormFile file, User us)
        {
            return SopManageMentDAL.DeviceSopAddSeave(eqptypecode, device, filename, filetypecode, file, us);
        }
        #endregion
        #region[系统设置,设备SOP删除]
        public static ToMessage DeviceSopDeleteSeave(string id, string eqpcode, string filepath, User us)
        {
            return SopManageMentDAL.DeviceSopDeleteSeave(id, eqpcode, filepath, us);
        }
        #endregion
        #region[系统设置,工艺SOP查询]
        public static ToMessage ProcessSopSearch(string search, string check, int startNum, int endNum, string prop, string order)
        {
            return SopManageMentDAL.ProcessSopSearch(search, check, startNum, endNum, prop, order);
        }
        #endregion
        #region[系统设置,工艺SOP上传获取最大版本号]
        public static ToMessage ProcessSopMaxVersion(string partcode, string routecode, string stepcode, string filetypecode, User us)
        {
            return SopManageMentDAL.ProcessSopMaxVersion(partcode, routecode, stepcode, filetypecode, us);
        }
        #endregion
        #region[系统设置,设备SOP新增]
        public static ToMessage ProcessSopAddSeave(string partcode, string routecode, string stepcode, string filename, string filetypecode,string version, IFormFile file, User us)
        {
            return SopManageMentDAL.ProcessSopAddSeave(partcode, routecode, stepcode, filename, filetypecode, version, file, us);
        }
        #endregion
        #region[系统设置,设备SOP删除]
        public static ToMessage ProcessSopDeleteSeave(string id, string partcode,string routecode,string stepcode, string filepath, User us)
        {
            return SopManageMentDAL.ProcessSopDeleteSeave(id, partcode, routecode, stepcode, filepath, us);
        }
        #endregion
    }
}
VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
@@ -96,9 +96,9 @@
        #endregion
        #region[MES工单查找历史引用最新工序信息]
        public static ToMessage MesOrderNewStepContent(string wkshopcode, string partcode, User us)
        public static ToMessage MesOrderNewStepContent(string wkshopcode,string routecode, string partcode, User us)
        {
            return WorkOrderDAL.MesOrderNewStepContent(wkshopcode, partcode, us);
            return WorkOrderDAL.MesOrderNewStepContent(wkshopcode, routecode, partcode, us);
        }
        #endregion
@@ -153,9 +153,9 @@
        #endregion
        #region [生产开报工:报工/外协(发料/收料)时条件判断及数据返回接口]
        public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode)
        public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode,User us)
        {
            return WorkOrderDAL.MesOrderStepStart(OperType, SelectType, wocode, stepcode);
            return WorkOrderDAL.MesOrderStepStart(OperType, SelectType, wocode, stepcode, us);
        }
        #endregion
VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs
@@ -122,7 +122,7 @@
                        //获取单据信息
                        sql = @"select distinct saleOrderCode,A.saleOrderDate,sum(A.saleOrderqty) as saleOrderqty
                                from TKimp_Ewo A 
                                where A.saleOrderCode<>'' " + search + " group by A.saleOrderCode,A.saleOrderDate  order by A.saleOrderDate desc";
                                where A.saleOrderCode<>'' and A.status<>'CLOSED' " + search + " group by A.saleOrderCode,A.saleOrderDate  order by A.saleOrderDate desc";
                        dt = DapperHelper.selectlist(sql, dynamicParams);
                        if (dt.Rows.Count > 0)
                        {
@@ -137,7 +137,7 @@
                                        select distinct E.wo,T.partcode,T.partname,T.partspec,sum(E.saleOrderqty) as saleOrderqty   
                                        from TKimp_Ewo E 
                                        left  join TMateriel_Info T on E.materiel_code=T.partcode 
                                        where E.saleOrderCode=@saleOrderCode
                                        where E.saleOrderCode=@saleOrderCode and E.status<>'CLOSED'
                                        group by E.wo,T.partcode,T.partname,T.partspec
                                        ) as AA
                                        left join
@@ -212,7 +212,7 @@
                                          where  S.isend='Y' and S.good_qty>0
                                          group by M.m_po
                                        ) as BB  on E.wo=BB.m_po
                                        where E.wo=@wo
                                        where E.wo=@wo and E.status<>'CLOSED'
                                        group by E.wo,T.partcode,T.partname,T.partspec,BB.good_qty";
                                dynamicParams.Add("@wo", dt.Rows[i]["wo"].ToString());
                                var data = DapperHelper.selectdata(sql, dynamicParams);
@@ -260,7 +260,7 @@
                        sql = @"select distinct A.wo_code,T.partcode,T.partname,T.partspec,A.lm_date,sum(A.plan_qty) as orderqty
                                from TK_Wrk_Man A  
                                left  join TMateriel_Info T on A.materiel_code=T.partcode
                                where 1=1 " + search + search1 + " group by A.wo_code,T.partcode,T.partname,T.partspec,A.lm_date  order by A.lm_date desc";
                                where A.status<>'CLOSED' " + search + search1 + " group by A.wo_code,T.partcode,T.partname,T.partspec,A.lm_date  order by A.lm_date desc";
                        dt = DapperHelper.selectlist(sql, dynamicParams);
                        if (dt.Rows.Count > 0)
                        {
VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
@@ -3448,7 +3448,7 @@
                            where S.materiel_code=@partcode
                            union all
                            select  materiel_code,step_seq,step_code,'0' as unprice,isbott,isend from TMateriel_Step 
                            where materiel_code+step_code
                            where materiel_code=@partcode and materiel_code+step_code
                            not in(select materiel_code+step_code  from TPrteEqp_Stad
                            where materiel_code=@partcode)
                            ) as A
@@ -3546,11 +3546,12 @@
                    total = 0; //总条数
                    sql = @"select *  from (
                            select A.id,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name,
                            D.stepcode,D.stepname,A.unprice
                            D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date
                            from TPrteEqp_Stad A
                            left join TMateriel_Info B on A.materiel_code=B.partcode
                            left join TFlw_Rout C on A.route_code=C.code
                            left join TStep D on A.step_code=D.stepcode
                            left join TUser U on A.lm_user=U.usercode
                            ) as AA where" + search;
                }
                else //工序版
@@ -3558,10 +3559,11 @@
                    search = search.Substring(3);//截取索引2后面的字符
                    total = 0; //总条数
                    sql = @"select *  from (
                            select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,A.unprice
                            select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date
                            from TPrteEqp_Stad A
                            left join TMateriel_Info B on A.materiel_code=B.partcode
                            left join TStep D on A.step_code=D.stepcode
                            left join TUser U on A.lm_user=U.usercode
                            ) as AA where" + search;
                }
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
@@ -364,6 +364,31 @@
        }
        #endregion
        #region[设备类型编码查找设备信息]
        public static ToMessage EqpTypecodeSeachEqpPermissions(string eqptypecode)
        {
            var sql = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                sql = @"select code,name from TEqpInfo where  enable='Y' and eqptype_code=@eqptypecode";
                dynamicParams.Add("@eqptypecode", eqptypecode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                mes.code = "200";
                mes.message = "查询成功!";
                mes.data = data;
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[仓库基础资料]
        public static ToMessage WareHouse()
        {
VueWebCoreApi/DLL/DAL/ProductModelDAL.cs
@@ -1167,22 +1167,16 @@
                                    lm_date = DateTime.Now.ToString()
                                }
                            });
                            //当前产品工艺路线对应工序是否已设置节拍工价
                            sql = @"select *  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode";
                            dynamicParams.Add("@partcode", json[0].partcode);
                            dynamicParams.Add("@routecode", json[0].children[i].code);
                            var data = DapperHelper.selectdata(sql, dynamicParams);
                            if (data.Rows.Count<=0)
                            {
                                //清除节拍工价表对应数据
                                sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode";
                                list.Add(new { str = sql, parm = new { partcode = json[0].partcode, routecode=json[0].children[i].code } });
                            }
                        }
                        //标记物料表关联工艺路线标识
                        sql = @"update TMateriel_Info set is_retdproc='Y',default_route=@defaultroute_code where partcode=@partcode";
                        list.Add(new { str = sql, parm = new { partcode = json[0].partcode, defaultroute_code = json[0].defaultroute_code } });
                        
                        //清除节拍工价表当前产品对应工艺路线不包含此次设置的其它数据
                        //string分割转string[]
                        string[] routcode = Array.ConvertAll<string, string>(string.Join(",", json[0].children.Select(s => s.code)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
                        sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and route_code not in @routecode";
                        list.Add(new { str = sql, parm = new { partcode = json[0].partcode, routecode= routcode } });
                    }
                }
                else //工序版
@@ -1223,22 +1217,16 @@
                                    lm_date = DateTime.Now.ToString()
                                }
                            });
                            //当前产品对应工序是否已设置节拍工价
                            sql = @"select *  from TPrteEqp_Stad where materiel_code=@partcode and step_code=@stepcode";
                            dynamicParams.Add("@partcode", json[0].partcode);
                            dynamicParams.Add("@stepcode", json[0].children[i].code);
                            var data = DapperHelper.selectdata(sql, dynamicParams);
                            if (data.Rows.Count <= 0)
                            {
                                //清除节拍工价表对应数据
                                sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and step_code=@stepcode";
                                list.Add(new { str = sql, parm = new { partcode = json[0].partcode, routecode = json[0].children[i].code } });
                            }
                        }
                        //标记物料表关联工艺路线标识
                        sql = @"update TMateriel_Info set is_retdproc='Y',default_route=@defaultroute_code where partcode=@partcode";
                        list.Add(new { str = sql, parm = new { partcode = json[0].partcode, defaultroute_code = json[0].defaultroute_code } });
                        //清除节拍工价表对应数据
                        //清除节拍工价表当前产品对应工序不包含此次设置的其它数据
                        //string分割转string[]
                        string[] stepcode = Array.ConvertAll<string, string>(string.Join(",", json[0].children.Select(s => s.code)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
                        sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and step_code not in @stepcode";
                        list.Add(new { str = sql, parm = new { partcode = json[0].partcode, stepcode = stepcode } });
                    }
                }
                bool aa = DapperHelper.DoTransaction(list);
@@ -1280,7 +1268,7 @@
                //获取物料数据
                sql = @"select M.partcode,M.partname,M.partspec,M.idunit as uom_code,T.name as uom_name,
                        M.idunitgroup as stocktype_code,D.name as stocktype_name,
                        M.idwarehouse as stck_code,S.name as stck_name
                        M.idwarehouse as stck_code,S.name as stck_name,M.default_route
                        from  TMateriel_Info M
                        left join  TUnit T on M.idunit=T.code
                        left join  TUnitGroup D on M.idunitgroup=D.code
VueWebCoreApi/DLL/DAL/SopManageMentDAL.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,463 @@
using Dapper;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using VueWebCoreApi.Models;
using VueWebCoreApi.Tools;
namespace VueWebCoreApi.DLL.DAL
{
    public class SopManageMentDAL
    {
        public static DataTable dt;    //定义全局变量dt
        public static bool res;       //定义全局变量dt
        public static ToMessage mes = new ToMessage(); //定义全局返回信息对象
        public static string strProcName = ""; //定义全局sql变量
        public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合
        public static SqlParameter[] parameters; //定义全局SqlParameter参数数组
        #region[系统设置,设备SOP查询]
        public static ToMessage DeviceSopSearch(string search, string check, int startNum, int endNum, string prop, string order)
        {
            var dynamicParams = new DynamicParameters();
            string sech = "";
            try
            {
                if (search != "" && search != null)
                {
                    sech += "and concat(isnull(AA.eqptypecode,''),isnull(AA.eqptypename,''),isnull(AA.eqpcode,''),isnull(AA.eqpname,''),isnull(AA.filetypecode,''),isnull(AA.filetypename,''),isnull(AA.filename,''),isnull(AA.version,''),isnull(AA.username,'')) like '%'+@search+'%' ";
                    dynamicParams.Add("@search", search);
                }
                if (check == "Y")
                {
                    sech += "and AA.rn=1 ";
                    dynamicParams.Add("@rn", 1);
                }
                if (sech == "")
                {
                    sech = "and 1=1 ";
                }
                sech = sech.Substring(3);//截取索引2后面的字符
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select AA.id,AA.eqptypecode,AA.eqptypename,AA.eqpcode,AA.eqpname,AA.filetypecode,AA.filetypename,AA.filename,AA.version,AA.filepath,
                            AA.username,AA.lm_date,AA.rn  from(
                            select top 100  A.id,A.eqptypecode,T.name as eqptypename,A.eqpcode,E.name as eqpname,A.filetypecode,
                            (case when A.filetypecode='P001' then '作业指导书' when A.filetypecode='P002' then '检验指导书' when A.filetypecode='P003' then '图纸'  end) as filetypename,
                            A.filename,A.version,A.filepath,U.username,A.lm_date,
                            row_number() over(partition by A.eqptypecode,A.eqpcode,A.filetypecode order by replace(A.version,'V','') desc) rn
                            from  TDeviceSop A
                            left  join TEqpInfo E on A.eqpcode=E.code
                            left  join TEqpType T on E.eqptype_code=T.code
                            left  join TUser U on A.lm_user=U.usercode
                            ) as AA  where  " + sech + "";
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                mes.code = "200";
                mes.message = "查询成功!";
                mes.count = total;
                mes.data = data.ToList();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,设备SOP新增]
        public static ToMessage DeviceSopAddSeave(string eqptypecode, string device, string filename, string filetypecode, IFormFile file, User us)
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            List<object> list = new List<object>();
            try
            {
                list.Clear();
                if (file == null || file.Length <= 0)
                {
                    mes.code = "300";
                    mes.message = "文件不能为空!";
                }
                else
                {
                    //获取上传文件,组合存储路径
                    string FileName = "SOP" + DateTime.Now.ToString("yyyyMMddhhmmss");
                    string filePath = "wwwroot/DeviceSopFile/" + FileName + file.FileName;     //通过此对象获取文件名(存文件地址)
                    string filePath1 = "DeviceSopFile/" + FileName + file.FileName;     //通过此对象获取文件名(存数据表地址)
                    // ä¿å­˜æ–‡ä»¶var stream = new FileStream(filePath, FileMode.Create)
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    //获取设备集合
                    string[] devicecode = Array.ConvertAll<string, string>(device.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string分割转string[]
                    for (int i = 0; i < devicecode.Length; i++)
                    {
                        string version = "";
                        //查询当前设备是否存在同文件类型的SOP文件,存在就增加版本号
                        sql = @"select isnull(max(substring(version,charindex('V',version)+1,len(version)-charindex('V',version))),0)+1 as version
                                from TDeviceSop
                                where eqptypecode=@eqptypecode and eqpcode=@eqpcode and filetypecode=@filetypecode";
                        dynamicParams.Add("@eqptypecode", eqptypecode);
                        dynamicParams.Add("@eqpcode", devicecode[i].ToString());
                        dynamicParams.Add("@filetypecode", filetypecode);
                        var data = DapperHelper.selectdata(sql, dynamicParams);
                        if (data.Rows.Count > 0)
                        {
                            version = "V" + data.Rows[0]["version"].ToString();
                        }
                        else
                        {
                            version = "V1";
                        }
                        //写入设备SOP表
                        sql = @"insert into  TDeviceSop(eqptypecode,eqpcode,filename,filetypecode,filepath,version,lm_user,lm_date)
                                values(@eqptypecode,@eqpcode,@filename,@filetypecode,@filepath,@version,@lm_user,@lm_date)";
                        list.Add(new
                        {
                            str = sql,
                            parm = new
                            {
                                eqptypecode = eqptypecode,
                                eqpcode = devicecode[i].ToString(),
                                filename = file.FileName,
                                filetypecode = filetypecode,
                                filepath = filePath1,
                                version = version,
                                lm_user = us.usercode,
                                lm_date = DateTime.Now.ToString()
                            }
                        });
                    }
                    bool aa = DapperHelper.DoTransaction(list);
                    if (aa)
                    {
                        //写入操作记录表
                        LogHelper.DbOperateLog(us.usercode, "新增设备SOP", "SOP文件:" + file.FileName + "设备:" + device.ToString(), us.usertype);
                        mes.code = "200";
                        mes.count = 0;
                        mes.message = "新增设备SOP成功!";
                        mes.data = null;
                    }
                    else
                    {
                        mes.code = "300";
                        mes.count = 0;
                        mes.message = "新增设备SOP失败!";
                        mes.data = null;
                    }
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,设备SOP删除]
        public static ToMessage DeviceSopDeleteSeave(string id, string eqpcode, string filepath, User us)
        {
            var sql = "";
            var dynamicParams = new DynamicParameters();
            List<object> list = new List<object>();
            try
            {
                list.Clear();
                //查询当前文件出去当前删除的,是否还被其他引用
                sql = @"select *  from TDeviceSop  where id<>@id  and filepath=@filepath";
                dynamicParams.Add("@id", id);
                dynamicParams.Add("@filepath", filepath);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count <= 0)
                {
                    // æž„建完整的文件路径
                    var filePath = Path.Combine("wwwroot", filepath);
                    // åˆ é™¤æ–‡ä»¶
                    System.IO.File.Delete(filePath);
                }
                sql = @"delete TDeviceSop where id=@id";
                list.Add(new { str = sql, parm = new { id = id } });
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
                {
                    //写入操作记录表
                    LogHelper.DbOperateLog(us.usercode, "删除设备SOP", "设备:" + eqpcode, us.usertype);
                    mes.code = "200";
                    mes.count = 0;
                    mes.message = "删除成功!";
                    mes.data = null;
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "删除失败!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,工艺SOP查询]
        public static ToMessage ProcessSopSearch(string search, string check, int startNum, int endNum, string prop, string order)
        {
            var dynamicParams = new DynamicParameters();
            string sech = "";
            try
            {
                if (search != "" && search != null)
                {
                    sech += "and concat(isnull(AA.materielcode,''),isnull(AA.materielname,''),isnull(AA.routecode,''),isnull(AA.routename,''),isnull(AA.stepcode,''),isnull(AA.stepname,''),isnull(AA.filetypecode,''),isnull(AA.filetypename,''),isnull(AA.filename,''),isnull(AA.version,''),isnull(AA.username,'')) like '%'+@search+'%' ";
                    dynamicParams.Add("@search", search);
                }
                if (check == "Y")
                {
                    sech += "and AA.rn=1 ";
                    dynamicParams.Add("@rn", 1);
                }
                if (sech == "")
                {
                    sech = "and 1=1 ";
                }
                sech = sech.Substring(3);//截取索引2后面的字符
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select AA.id,AA.materielcode,AA.materielname,AA.routecode,AA.routename,AA.stepcode,AA.stepname,AA.filetypecode,AA.filetypename,AA.filename,AA.version,AA.filepath,
                            AA.username,AA.lm_date,AA.rn  from(
                            select top 100  A.id,A.materielcode,M.partname as materielname,A.routecode,R.name as routename,A.stepcode,S.stepname,A.filetypecode,
                            (case when A.filetypecode='P001' then '作业指导书' when A.filetypecode='P002' then '检验指导书' when A.filetypecode='P003' then '图纸'  end) as filetypename,
                            A.filename,A.version,A.filepath,U.username,A.lm_date,
                            row_number() over(partition by A.materielcode,A.routecode,A.stepcode,A.filetypecode order by replace(A.version,'V','') desc) rn
                            from  TProcessSop A
                            left  join TMateriel_Info M on A.materielcode=M.partcode
                            left  join TFlw_Rout R on A.routecode=R.code
                            left  join TStep S on A.stepcode=S.stepcode
                            left  join TUser U on A.lm_user=U.usercode
                            ) as AA  where  " + sech + "";
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                mes.code = "200";
                mes.message = "查询成功!";
                mes.count = total;
                mes.data = data.ToList();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,工艺SOP上传获取最大版本号]
        public static ToMessage ProcessSopMaxVersion(string partcode, string routecode, string stepcode, string filetypecode, User us)
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            string sech = "";
            try
            {
                dynamic dynObj = JObject.Parse(us.mesSetting);
                bool route = dynObj.route;
                if (route) //按工艺路线模式
                {
                    sech += " and routecode=@routecode and stepcode=@stepcode";
                    dynamicParams.Add("@routecode", routecode);
                    dynamicParams.Add("@stepcode", stepcode);
                }
                else //工序模式
                {
                    sech += " and stepcode=@stepcode";
                    dynamicParams.Add("@stepcode", stepcode);
                }
                //获取SOP文件作业文件上传获取最大版本号
                sql = @"select isnull(max(substring(version,charindex('V',version)+1,len(version)-charindex('V',version))),0)+1 as file_version
                        from TProcessSop where materielcode=@materielcode and filetypecode=@filetypecode "+sech;
                dynamicParams.Add("@materielcode", partcode);
                dynamicParams.Add("@filetypecode", filetypecode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    mes.code = "200";
                    mes.message = "获取版本号成功!";
                    mes.data = "V" + data.Rows[0]["file_version"].ToString();
                }
                else
                {
                    mes.code = "300";
                    mes.message = "获取版本号失败!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,工艺SOP新增]
        public static ToMessage ProcessSopAddSeave(string partcode, string routecode, string stepcode, string filename, string filetypecode, string version, IFormFile file, User us)
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            List<object> list = new List<object>();
            try
            {
                list.Clear();
                if (file == null || file.Length <= 0)
                {
                    mes.code = "300";
                    mes.message = "文件不能为空!";
                }
                else
                {
                    //获取上传文件,组合存储路径
                    string FileName = "SOP" + DateTime.Now.ToString("yyyyMMddhhmmss");
                    string filePath = "wwwroot/ProcessSopFile/" + FileName + file.FileName;     //通过此对象获取文件名(存文件地址)
                    string filePath1 = "ProcessSopFile/" + FileName + file.FileName;     //通过此对象获取文件名(存数据表地址)
                    // ä¿å­˜æ–‡ä»¶var stream = new FileStream(filePath, FileMode.Create)
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    //写入设备SOP表
                    sql = @"insert into  TProcessSop(materielcode,routecode,stepcode,filetypecode,filename,filepath,version,lm_user,lm_date)
                                values(@materielcode,@routecode,@stepcode,@filetypecode,@filename,@filepath,@version,@lm_user,@lm_date)";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            materielcode = partcode,
                            routecode = routecode,
                            stepcode = stepcode,
                            filetypecode = filetypecode,
                            filename = file.FileName,
                            filepath = filePath1,
                            version = version,
                            lm_user = us.usercode,
                            lm_date = DateTime.Now.ToString()
                        }
                    });
                    bool aa = DapperHelper.DoTransaction(list);
                    if (aa)
                    {
                        //写入操作记录表
                        LogHelper.DbOperateLog(us.usercode, "新增工艺SOP", "产品:"+partcode+" SOP文件:" + file.FileName + " å·¥è‰ºè·¯çº¿:" + routecode ?? "" + " å·¥åº:" + stepcode.ToString(), us.usertype);
                        mes.code = "200";
                        mes.count = 0;
                        mes.message = "新增设备SOP成功!";
                        mes.data = null;
                    }
                    else
                    {
                        mes.code = "300";
                        mes.count = 0;
                        mes.message = "新增设备SOP失败!";
                        mes.data = null;
                    }
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[系统设置,工艺SOP删除]
        public static ToMessage ProcessSopDeleteSeave(string id, string partcode, string routecode, string stepcode, string filepath, User us)
        {
            var sql = "";
            var dynamicParams = new DynamicParameters();
            List<object> list = new List<object>();
            try
            {
                list.Clear();
                //查询当前文件出去当前删除的,是否还被其他引用
                sql = @"select *  from TProcessSop  where id<>@id  and filepath=@filepath";
                dynamicParams.Add("@id", id);
                dynamicParams.Add("@filepath", filepath);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count <= 0)
                {
                    // æž„建完整的文件路径
                    var filePath = Path.Combine("wwwroot", filepath);
                    // åˆ é™¤æ–‡ä»¶
                    System.IO.File.Delete(filePath);
                }
                sql = @"delete TProcessSop where id=@id";
                list.Add(new { str = sql, parm = new { id = id } });
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
                {
                    //写入操作记录表
                    LogHelper.DbOperateLog(us.usercode, "删除工艺SOP", "产品:" + partcode+" SOP文件地址:"+filepath+" å·¥è‰ºè·¯çº¿:"+ routecode ?? "" + " å·¥åº:"+stepcode, us.usertype);
                    mes.code = "200";
                    mes.count = 0;
                    mes.message = "删除成功!";
                    mes.data = null;
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "删除失败!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
    }
}
VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs
@@ -1,9 +1,11 @@
using Dapper;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using VueWebCoreApi.Models;
VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
@@ -624,7 +624,7 @@
                }
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,R.name as route_name,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                            A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser
                            from TK_Wrk_Man A
                            left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid
@@ -633,6 +633,7 @@
                            left join TSecStck D on A.stck_code=D.code 
                            left join TUser U on A.lm_user=U.usercode 
                            left join TOrganization L on  C.parent_id=L.id
                            left join TFlw_Rout R on A.route_code=R.code
                            where A.is_delete<>'1' " + search;
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                mes.code = "200";
@@ -775,10 +776,9 @@
                if (data_sources == "ERP")  //数据来源ERP
                {
                    //查询订单任务总数
                    sql = @"select qty  from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
                    sql = @"select qty,relse_qty  from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
                    dynamicParams.Add("@sourceid", sourceid);
                    dynamicParams.Add("@sourcewo", sourcewo);
                    dynamicParams.Add("@wocode", wocode);
                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
                    //查询当前工单可修改数量=订单总数-已下达工单总数
                    sql = @"select isnull(sum(plan_qty),0) as plan_qty   from TK_Wrk_Man 
@@ -836,16 +836,26 @@
        #region[MES工单新增、编辑提交]
        public static ToMessage AddUpdateMesOrder(string operType, WorkList json, User us)
        {
            string sql = "";
            string sql = "", route_code = "";
            var dynamicParams = new DynamicParameters();
            List<object> list = new List<object>();
            try
            {
                dynamic dynObj = JObject.Parse(us.mesSetting);
                bool route = dynObj.route;
                if (route) //工艺路线版
                {
                    route_code = json.routecode;
                }
                else //工序版
                {
                    route_code = null;
                }
                if (operType == "Add")
                {
                    //写入工单表
                    sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,sourceid,m_po,saleOrderDeliveryDate,plan_startdate,plan_enddate,piroque,isaps,data_sources,isstep)
                                values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@sourceid,@m_po,@saleOrderDeliveryDate,@plan_startdate,@plan_enddate,@orderlev,@isaps,@data_sources,@isstep)";
                    sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,route_code,sourceid,m_po,saleOrderDeliveryDate,plan_startdate,plan_enddate,piroque,isaps,data_sources,isstep)
                                values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@route_code,@sourceid,@m_po,@saleOrderDeliveryDate,@plan_startdate,@plan_enddate,@orderlev,@isaps,@data_sources,@isstep)";
                    list.Add(new
                    {
                        str = sql,
@@ -859,6 +869,7 @@
                            lm_user = us.usercode,
                            lm_date = DateTime.Now.ToString(),
                            materiel_code = json.partcode,
                            route_code = route_code,
                            sourceid = json.sourceid == "" ? null : json.sourceid, //无源单时赋值NULL
                            m_po = json.sourcewo,
                            saleOrderDeliveryDate = json.deliverydate,
@@ -873,8 +884,8 @@
                    //写入工序任务表
                    for (int i = 0; i < json.WorkListSub.Count; i++)
                    {
                        sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
                                values(@wo_code,@seq,@step_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
                        sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,route_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
                                values(@wo_code,@seq,@step_code,@route_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
                        list.Add(new
                        {
                            str = sql,
@@ -883,6 +894,7 @@
                                wo_code = json.wocode,
                                seq = json.WorkListSub[i].stepseq,
                                step_code = json.WorkListSub[i].stepcode,
                                route_code = route_code,
                                stepprice = json.WorkListSub[i].stepprice,
                                plan_qty = json.woqty,
                                status = json.wostatus,
@@ -915,7 +927,7 @@
                {
                    //修改工单表
                    sql = @"update TK_Wrk_Man set wotype=@wotype,wkshp_code=@wkshp_code,plan_qty=@plan_qty,lm_user=@lm_user,lm_date=@lm_date,
                            materiel_code=@materiel_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,plan_startdate=@plan_startdate,plan_enddate=@plan_enddate,isstep=@isstep
                            materiel_code=@materiel_code,route_code=@route_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,plan_startdate=@plan_startdate,plan_enddate=@plan_enddate,isstep=@isstep
                            where wo_code=@wo_code";
                    list.Add(new
                    {
@@ -927,6 +939,7 @@
                            wkshp_code = json.wkshopcode,
                            plan_qty = json.woqty,
                            materiel_code = json.partcode,
                            route_code = route_code,
                            sourceid = json.sourceid == "" ? null : json.sourceid, //无源单时赋值NULL
                            m_po = json.sourcewo,
                            saleOrderDeliveryDate = json.deliverydate,
@@ -950,8 +963,8 @@
                    //写入工单工序表
                    for (int i = 0; i < json.WorkListSub.Count; i++)
                    {
                        sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
                                values(@wo_code,@seq,@step_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
                        sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,route_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
                                values(@wo_code,@seq,@step_code,@route_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
                        list.Add(new
                        {
                            str = sql,
@@ -960,6 +973,7 @@
                                wo_code = json.wocode,
                                seq = json.WorkListSub[i].stepseq,
                                step_code = json.WorkListSub[i].stepcode,
                                route_code = route_code,
                                stepprice = json.WorkListSub[i].stepprice,
                                plan_qty = json.woqty,
                                status = json.wostatus,
@@ -969,6 +983,45 @@
                                lm_date = DateTime.Now.ToString()
                            }
                        });
                    }
                    //判断源头单据是否来源ERP
                    if (json.data_sources == "ERP")
                    {
                        //判断工单修改数量差值是否为0
                        if (json.difference != "0")
                        {
                            string staus = "";
                            //查询订单总数,已下达数量
                            sql = @"select qty,relse_qty  from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
                            dynamicParams.Add("@sourceid", json.sourceid);
                            dynamicParams.Add("@sourcewo", json.sourcewo);
                            var data0 = DapperHelper.selectdata(sql, dynamicParams);
                            //当前工单可修改数量=订单数量-非当前工单总下达工单数量
                            decimal qty = decimal.Parse(data0.Rows[0]["qty"].ToString());//订单总数
                            decimal relse_qty = decimal.Parse(data0.Rows[0]["relse_qty"].ToString());//订单已下达总数
                            relse_qty = relse_qty + decimal.Parse(json.difference);//新的下达数量=原始下达数量+差值(正负)
                            if (qty == relse_qty)
                            {
                                staus = "CREATED"; //全部下达
                            }
                            else
                            {
                                staus = "CREATING";//部分下达
                            }
                            //更新订单表状态、已下达数量
                            sql = @"update TKimp_Ewo set status=@status,relse_qty=@relse_qty where id=@sourceid and wo=@sourcewo";
                            list.Add(new
                            {
                                str = sql,
                                parm = new
                                {
                                    status = staus,
                                    relse_qty = relse_qty,
                                    sourceid = json.sourceid,
                                    sourcewo = json.sourcewo
                                }
                            });
                        }
                    }
                    bool aa = DapperHelper.DoTransaction(list);
@@ -1085,12 +1138,33 @@
        #endregion
        #region[MES工单查找历史引用最新工序信息]
        public static ToMessage MesOrderNewStepContent(string wkshopcode, string partcode, User us)
        public static ToMessage MesOrderNewStepContent(string wkshopcode, string routecode, string partcode, User us)
        {
            var sql = "";
            List<object> list = new List<object>();
            var dynamicParams = new DynamicParameters();
            try
            {
                dynamic dynObj = JObject.Parse(us.mesSetting);
                bool route = dynObj.route;
                if (route) //工艺路线版
                {
                    //MES工单查找历史引用最新工序信息
                    sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend
                        from TK_Wrk_Step S
                        inner join (
                        select top 1 A.wo_code,A.route_code   from TK_Wrk_Man A
                        inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code
                        where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode
                        order by A.lm_date desc
                        ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code
                        left join TStep  T on S.step_code=T.stepcode
                        order by S.seq";
                    dynamicParams.Add("@wkshopcode", wkshopcode);
                    dynamicParams.Add("@partcode", partcode);
                    dynamicParams.Add("@routecode", routecode);
                }
                else
            {
                //MES工单查找历史引用最新工序信息
                sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend
@@ -1105,6 +1179,8 @@
                        order by S.seq";
                dynamicParams.Add("@wkshopcode", wkshopcode);
                dynamicParams.Add("@partcode", partcode);
                }
                var data = DapperHelper.selectdata(sql, dynamicParams);
                mes.code = "200";
                mes.count = data.Rows.Count;
@@ -1735,18 +1811,34 @@
        #endregion
        #region [生产开报工:报工/外协(发料/收料)时条件判断及数据返回接口]
        public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode)
        public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode, User us)
        {
            var dynamicParams = new DynamicParameters();
            try
            {
                dynamic dynObj = JObject.Parse(us.mesSetting);
                bool isOrder = dynObj.isOrder;
                switch (OperType)
                {
                    case "ZZ":
                        if (isOrder) //按序生产
                        {
                        mes = ScanStartReport.ZZEncodingSeach(wocode, stepcode);
                        }
                        else //不按序生产
                        {
                            mes = ScanStartReport.NoZZEncodingSeach(wocode, stepcode);
                        }
                        break;
                    case "WX":
                        if (isOrder) //按序收发料
                        {
                        mes = ScanStartReport.WXEncodingSeach(SelectType, wocode, stepcode);
                        }
                        else //不按序收发料
                        {
                            mes = ScanStartReport.NoWXEncodingSeach(SelectType, wocode, stepcode);
                        }
                        break;
                    default:
                        break;
@@ -2686,12 +2778,26 @@
            var dynamicParams = new DynamicParameters();
            try
            {
                dynamic dynObj = JObject.Parse(us.mesSetting);
                bool isOrder = dynObj.isOrder;
                //获取此次报工调整提交的数据(合格数量、不良数量、工废数量、料废数量)
                decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //报工数量(合格)
                decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//不良数量汇总
                decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//工废数量汇总
                decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//料废数量汇总
                decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//不良数量差值汇总
                decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//工废数量差值汇总
                decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//料废数量差值汇总
                string date = DateTime.Now.ToString(); //获取系统时间
                if (isOrder) //按序
                {
                //控制逻辑:首道工序调整-> æœ¬é“工序当前调整总数(合格+不良+报废)+本道工序非当前报工总数(合格+不良+报废)>任务数量   ==不能大于任务数量
                //控制逻辑:首道工序调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废)   ==不能小于下道报工总数
                //控制逻辑:末道工序调整-> æœ¬é“工序当前调整总数(合格+不良+报废)+本道工序非当前报工总数(合格+不良+报废)>上道工序报工合格总数   ==不能大于上道工序报工合格总数
                //控制逻辑:中间工序调整-> æœ¬é“工序当前调整总数(合格+不良+报废)+本道工序非当前报工总数(合格+不良+报废)>上道工序报工合格总数   ==不能大于上道工序报工合格总数
                //控制逻辑:中间工序调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废)   ==不能小于下道报工总数
                string date = DateTime.Now.ToString(); //获取系统时间
                list.Clear();
                //获取当前工序上道工序及属性
                sql = @"select T.stepcode,T.stepname,T.flwtype from TK_Wrk_Step A
@@ -2710,14 +2816,6 @@
                //判断当前工序是自制工序还是外协工序
                if (json[0].flw_type.ToString() == "Z")//自制工序
                {
                    //获取此次报工调整提交的数据(合格数量、不良数量、工废数量、料废数量)
                    decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //报工数量(合格)
                    decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//不良数量汇总
                    decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//工废数量汇总
                    decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//料废数量汇总
                    decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//不良数量差值汇总
                    decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//工废数量差值汇总
                    decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//料废数量差值汇总
                    //首道工序的报工
                    if (json[0].first_choke == "Y")
                    {
@@ -2992,7 +3090,285 @@
                            }
                        }
                    }
                    }
                    if (json[0].flw_type.ToString() == "W")//外协工序
                    {
                        //查询当前首道工序非此次供应商收料:总收料数量
                        sql = @"select isnull(sum(sqty),0) as sqty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code<>@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        dynamicParams.Add("@wx_code", json[0].wxcode);
                        var dt_c = DapperHelper.selectdata(sql, dynamicParams);
                        //获取当前工序、供应商对应的发料数量
                        sql = @"select isnull(sum(fqty),0) as fqty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        dynamicParams.Add("@wx_code", json[0].wxcode);
                        var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
                        //首道工序的收料
                        if (json[0].first_choke == "Y")
                        {
                            //查询当前首道工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                            sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                            dynamicParams.Add("@wo_code", json[0].wo_code);
                            dynamicParams.Add("@id", json[0].id);
                            dynamicParams.Add("@step_code", json[0].step_code);
                            dynamicParams.Add("@wx_code", json[0].wxcode);
                            var dt = DapperHelper.selectdata(sql, dynamicParams);
                            decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前工序非本次收料总数
                            decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前工序非本次报工总不良数
                            decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前工序非本次报工总工废数
                            decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前工序非本次报工总料废数
                            //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量
                            decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
                            if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                            {
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前外协工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                                mes.data = null;
                                return mes;
                            }
                            //判断是否存在下道工序及属性
                            if (next.Rows.Count > 0)
                            {
                                if (next.Rows[0]["flwtype"].ToString() == "Z")
                                {
                                    //查询当前工序下道工序:总报工数量、总不良数量、总报废数量
                                    sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                    from TK_Wrk_Record where wo_code=@wo_code and style='B'  and step_seq=@step_seq+1";
                                    dynamicParams.Add("@wo_code", json[0].wo_code);
                                    dynamicParams.Add("@step_seq", json[0].step_seq);
                                    var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                    if (dt0.Rows.Count > 0)
                                    {
                                        //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量
                                        decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序报工总数量
                                        decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString());  //下道工序不良总数量
                                        decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString());  //下道工序工废总数量
                                        decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());  //下道工序料废总数量
                                        decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
                                        //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数
                                        if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
                                        {
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.message = "当前外协工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!";
                                            mes.data = null;
                                            return mes;
                                        }
                                    }
                                }
                                else
                                {
                                    //查询当前工序下道工序:总发料数量
                                    sql = @"select isnull(sum(fqty),0) as good_qty
                                    from TK_Wrk_OutRecord where wo_code=@wo_code and style='F'  and step_seq=@step_seq+1";
                                    dynamicParams.Add("@wo_code", json[0].wo_code);
                                    dynamicParams.Add("@step_seq", json[0].step_seq);
                                    var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                    if (dt0.Rows.Count > 0)
                                    {
                                        //判断当前工序:发料总数数量
                                        decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序发料总数量
                                                                                                                     //判断(当前非本次收料数+本次报工调整收料数)<下道工序发料总数
                                        if ((notthis_reportqty + this_reportqty) < last_reportqty)
                                        {
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.message = "当前外协工序收料总数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!";
                                            mes.data = null;
                                            return mes;
                                        }
                                    }
                                }
                            }
                        }
                        //末道工序的报工
                        else if (json[0].last_choke == "Y")
                        {
                            //查询当前末道报工工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                            sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code  and wx_code=@wx_code";
                            dynamicParams.Add("@wo_code", json[0].wo_code);
                            dynamicParams.Add("@id", json[0].id);
                            dynamicParams.Add("@step_code", json[0].step_code);
                            var dt = DapperHelper.selectdata(sql, dynamicParams);
                            decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前末道工序非本次收料总数
                            decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前末道工序非本次报工总数
                            decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前末道工序非本次报工工废总数
                            decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前末道工序非本次报工料废总数
                                                                                                                        //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前末道工序非本次收料总数+当前末道工序非本次不良总数+当前末道工序非本次工废总数+当前末道工序非本次料废总数
                            decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
                            //判断当前工序供应商收料总数>当前工序供应商对应发料数量
                            if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                            {
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前工序供应商收料总数量:【" + updatereportsumqty + "】不能大于工序供应商发料总数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                                mes.data = null;
                                return mes;
                            }
                        }
                        else //中间工序的报工
                        {
                            //查询当前首道工序供应商非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                            sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                            dynamicParams.Add("@wo_code", json[0].wo_code);
                            dynamicParams.Add("@id", json[0].id);
                            dynamicParams.Add("@step_code", json[0].step_code);
                            dynamicParams.Add("@wx_code", json[0].wxcode);
                            var dt = DapperHelper.selectdata(sql, dynamicParams);
                            decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前工序非本次收料总数
                            decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前工序非本次报工总不良数
                            decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前工序非本次报工总工废数
                            decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前工序非本次报工总料废数
                                                                                                                       //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量
                            decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
                            if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                            {
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前外协工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                                mes.data = null;
                                return mes;
                            }
                            //判断是否存在下道工序及属性
                            if (next.Rows.Count > 0)
                            {
                                if (next.Rows[0]["flwtype"].ToString() == "Z")
                                {
                                    //查询当前工序下道工序:总报工数量、总不良数量、总报废数量
                                    sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                    from TK_Wrk_Record where wo_code=@wo_code and style='B'  and step_seq=@step_seq+1";
                                    dynamicParams.Add("@wo_code", json[0].wo_code);
                                    dynamicParams.Add("@step_seq", json[0].step_seq);
                                    var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                    if (dt0.Rows.Count > 0)
                                    {
                                        //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量
                                        decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序报工总数量
                                        decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString());  //下道工序不良总数量
                                        decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString());  //下道工序工废总数量
                                        decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());  //下道工序料废总数量
                                        decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
                                        //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数
                                        if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
                                        {
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.message = "当前外协工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!";
                                            mes.data = null;
                                            return mes;
                                        }
                                    }
                                }
                                else
                                {
                                    //查询当前工序下道工序:总发料数量
                                    sql = @"select isnull(sum(fqty),0) as good_qty
                                    from TK_Wrk_OutRecord where wo_code=@wo_code and style='F'  and step_seq=@step_seq+1";
                                    dynamicParams.Add("@wo_code", json[0].wo_code);
                                    dynamicParams.Add("@step_seq", json[0].step_seq);
                                    var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                    if (dt0.Rows.Count > 0)
                                    {
                                        //判断当前工序:发料总数数量
                                        decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序发料总数量
                                                                                                                     //判断(当前非本次收料数+本次报工调整收料数+非当前供应商同工序收料总数)<下道工序发料总数
                                        if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_reportqty)
                                        {
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.message = "当前外协工序收料总数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!";
                                            mes.data = null;
                                            return mes;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else //不按序
                {
                    //控制逻辑:当前工序报工调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废)   ==不能小于下道报工总数
                    list.Clear();
                    //判断当前工序是自制工序还是外协工序
                    if (json[0].flw_type.ToString() == "Z")
                    {
                       //查询当前报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量
                        sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        var dt = DapperHelper.selectdata(sql, dynamicParams);
                        decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前工序非本次报工总数
                        decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前工序非本次报工总不良数
                        decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前工序非本次报工总工废数
                        decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前工序非本次报工总料废数
                        //判断:当前工序报工记录:本次报工数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次报工总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>工单任务数量
                        decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
                        if (updatereportsumqty > decimal.Parse(json[0].task_qty.ToString()))
                        {
                            mes.code = "300";
                            mes.count = 0;
                            mes.message = "当前工序修改报工总数量:【" + updatereportsumqty + "】不能大于工单任务数量:【" + json[0].task_qty.ToString() + "】!";
                            mes.data = null;
                            return mes;
                        }
                    }
                    if (json[0].flw_type.ToString() == "W")
                    {
                        //获取当前工序、供应商对应的总发料数量
                        sql = @"select isnull(sum(fqty),0) as fqty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        dynamicParams.Add("@wx_code", json[0].wxcode);
                        var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
                        //查询当前工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                        sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code  and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        var dt = DapperHelper.selectdata(sql, dynamicParams);
                        decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前末道工序非本次收料总数
                        decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前末道工序非本次报工总数
                        decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前末道工序非本次报工工废总数
                        decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前末道工序非本次报工料废总数
                       //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数
                        decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
                        //判断当前工序供应商收料总数>当前工序供应商对应发料数量
                        if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                        {
                            mes.code = "300";
                            mes.count = 0;
                            mes.message = "当前工序供应商收料总数量:【" + updatereportsumqty + "】不能大于工序供应商发料总数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                            mes.data = null;
                            return mes;
                        }
                    }
                }
                switch (json[0].flw_type.ToString())
                {
                    case "Z":
                    ///////////////////////////////修改报工//////////////////////////////
                    //回写对应的报工记录子表合格数量、不良数量、报废数量
@@ -3092,222 +3468,8 @@
                            }
                        });
                    }
                }
                if (json[0].flw_type.ToString() == "W")//外协工序
                {
                    //查询当前首道工序非此次供应商收料:总收料数量
                    sql = @"select isnull(sum(sqty),0) as sqty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code<>@wx_code";
                    dynamicParams.Add("@wo_code", json[0].wo_code);
                    dynamicParams.Add("@id", json[0].id);
                    dynamicParams.Add("@step_code", json[0].step_code);
                    dynamicParams.Add("@wx_code", json[0].wxcode);
                    var dt_c = DapperHelper.selectdata(sql, dynamicParams);
                    //获取此次报工调整提交的数据(收料数量、不良数量、工废数量、料废数量)
                    decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //收料数量
                    decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//不良数量汇总
                    decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//工废数量汇总
                    decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//料废数量汇总
                    decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//不良数量差值汇总
                    decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//工废数量差值汇总
                    decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//料废数量差值汇总
                    //获取当前工序、供应商对应的发料数量
                    sql = @"select isnull(sum(fqty),0) as fqty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                    dynamicParams.Add("@wo_code", json[0].wo_code);
                    dynamicParams.Add("@id", json[0].id);
                    dynamicParams.Add("@step_code", json[0].step_code);
                    dynamicParams.Add("@wx_code", json[0].wxcode);
                    var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
                    //首道工序的收料
                    if (json[0].first_choke == "Y")
                    {
                        //查询当前首道工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                        sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        dynamicParams.Add("@wx_code", json[0].wxcode);
                        var dt = DapperHelper.selectdata(sql, dynamicParams);
                        decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前工序非本次收料总数
                        decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前工序非本次报工总不良数
                        decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前工序非本次报工总工废数
                        decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前工序非本次报工总料废数
                        //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量
                        decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
                        if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                        {
                            mes.code = "300";
                            mes.count = 0;
                            mes.message = "当前首道工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                            mes.data = null;
                            return mes;
                        }
                        //判断是否存在下道工序及属性
                        if (next.Rows.Count > 0)
                        {
                            if (next.Rows[0]["flwtype"].ToString() == "Z")
                            {
                                //查询当前工序下道工序:总报工数量、总不良数量、总报废数量
                                sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                    from TK_Wrk_Record where wo_code=@wo_code and style='B'  and step_seq=@step_seq+1";
                                dynamicParams.Add("@wo_code", json[0].wo_code);
                                dynamicParams.Add("@step_seq", json[0].step_seq);
                                var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (dt0.Rows.Count > 0)
                                {
                                    //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量
                                    decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序报工总数量
                                    decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString());  //下道工序不良总数量
                                    decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString());  //下道工序工废总数量
                                    decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());  //下道工序料废总数量
                                    decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
                                    //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数
                                    if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
                                    {
                                        mes.code = "300";
                                        mes.count = 0;
                                        mes.message = "当前首道工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!";
                                        mes.data = null;
                                        return mes;
                                    }
                                }
                            }
                            else
                            {
                                //查询当前工序下道工序:总发料数量
                                sql = @"select isnull(sum(fqty),0) as good_qty
                                    from TK_Wrk_OutRecord where wo_code=@wo_code and style='F'  and step_seq=@step_seq+1";
                                dynamicParams.Add("@wo_code", json[0].wo_code);
                                dynamicParams.Add("@step_seq", json[0].step_seq);
                                var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (dt0.Rows.Count > 0)
                                {
                                    //判断当前工序:发料总数数量
                                    decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序发料总数量
                                    //判断(当前非本次收料数+本次报工调整收料数)<下道工序发料总数
                                    if ((notthis_reportqty + this_reportqty) < last_reportqty)
                                    {
                                        mes.code = "300";
                                        mes.count = 0;
                                        mes.message = "当前首道工序收料总数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!";
                                        mes.data = null;
                                        return mes;
                                    }
                                }
                            }
                        }
                    }
                    //末道工序的报工
                    else if (json[0].last_choke == "Y")
                    {
                        //查询当前末道报工工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                        sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code  and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        var dt = DapperHelper.selectdata(sql, dynamicParams);
                        decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前末道工序非本次收料总数
                        decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前末道工序非本次报工总数
                        decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前末道工序非本次报工工废总数
                        decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前末道工序非本次报工料废总数
                        //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前末道工序非本次收料总数+当前末道工序非本次不良总数+当前末道工序非本次工废总数+当前末道工序非本次料废总数
                        decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
                        //判断当前工序供应商收料总数>当前工序供应商对应发料数量
                        if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                        {
                            mes.code = "300";
                            mes.count = 0;
                            mes.message = "当前工序供应商收料总数量:【" + updatereportsumqty + "】不能大于工序供应商发料总数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                            mes.data = null;
                            return mes;
                        }
                    }
                    else //中间工序的报工
                    {
                        //查询当前首道工序供应商非此次收料:总收料数量、总不良数量、总工废数量、总料废数量
                        sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
                        dynamicParams.Add("@wo_code", json[0].wo_code);
                        dynamicParams.Add("@id", json[0].id);
                        dynamicParams.Add("@step_code", json[0].step_code);
                        dynamicParams.Add("@wx_code", json[0].wxcode);
                        var dt = DapperHelper.selectdata(sql, dynamicParams);
                        decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString());  //当前工序非本次收料总数
                        decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString());  //当前工序非本次报工总不良数
                        decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString());  //当前工序非本次报工总工废数
                        decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString());  //当前工序非本次报工总料废数
                        //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量
                        decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
                        if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
                        {
                            mes.code = "300";
                            mes.count = 0;
                            mes.message = "当前首道工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!";
                            mes.data = null;
                            return mes;
                        }
                        //判断是否存在下道工序及属性
                        if (next.Rows.Count > 0)
                        {
                            if (next.Rows[0]["flwtype"].ToString() == "Z")
                            {
                                //查询当前工序下道工序:总报工数量、总不良数量、总报废数量
                                sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
                                    from TK_Wrk_Record where wo_code=@wo_code and style='B'  and step_seq=@step_seq+1";
                                dynamicParams.Add("@wo_code", json[0].wo_code);
                                dynamicParams.Add("@step_seq", json[0].step_seq);
                                var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (dt0.Rows.Count > 0)
                                {
                                    //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量
                                    decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序报工总数量
                                    decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString());  //下道工序不良总数量
                                    decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString());  //下道工序工废总数量
                                    decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());  //下道工序料废总数量
                                    decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
                                    //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数
                                    if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
                                    {
                                        mes.code = "300";
                                        mes.count = 0;
                                        mes.message = "当前首道工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!";
                                        mes.data = null;
                                        return mes;
                                    }
                                }
                            }
                            else
                            {
                                //查询当前工序下道工序:总发料数量
                                sql = @"select isnull(sum(fqty),0) as good_qty
                                    from TK_Wrk_OutRecord where wo_code=@wo_code and style='F'  and step_seq=@step_seq+1";
                                dynamicParams.Add("@wo_code", json[0].wo_code);
                                dynamicParams.Add("@step_seq", json[0].step_seq);
                                var dt0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (dt0.Rows.Count > 0)
                                {
                                    //判断当前工序:发料总数数量
                                    decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString());  //下道工序发料总数量
                                    //判断(当前非本次收料数+本次报工调整收料数+非当前供应商同工序收料总数)<下道工序发料总数
                                    if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_reportqty)
                                    {
                                        mes.code = "300";
                                        mes.count = 0;
                                        mes.message = "当前首道工序收料总数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!";
                                        mes.data = null;
                                        return mes;
                                    }
                                }
                            }
                        }
                    }
                        break;
                    case "W":
                    ///////////////////////////////修改报工//////////////////////////////
                    //回写对应的外协记录子表收料数量、不良数量、报废数量
@@ -3409,8 +3571,10 @@
                            }
                        });
                    }
                        break;
                    default:
                        break;
                }
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
                {
VueWebCoreApi/Models/WorkData/WorkList.cs
@@ -32,6 +32,10 @@
        /// </summary>
        public string partcode { get; set; }
        /// <summary>
        /// å·¥è‰ºè·¯çº¿ç¼–码
        /// </summary>
        public string routecode { get; set; }
        /// <summary>
        /// å·¥å•数量
        /// </summary>
        public string woqty { get; set; }
@@ -56,6 +60,10 @@
        /// </summary>
        public string data_sources { get; set; }
        /// <summary>
        /// ä¿®æ”¹æ•°é‡å·®å€¼
        /// </summary>
        public string difference { get; set; }
        /// <summary>
        /// æ˜¯å¦å…³è”工序
        /// </summary>
        public string isstep { get; set; }
VueWebCoreApi/Startup.cs
@@ -80,6 +80,7 @@
                string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
                string xmlPath = Path.Combine(basePath, "VueWebCoreApi.xml");
                c.IncludeXmlComments(xmlPath, true);
            });
            #endregion
VueWebCoreApi/Tools/ScanStartReport.cs
@@ -13,7 +13,7 @@
        public static ToMessage mes = new ToMessage(); //定义全局返回信息对象
        #region[生产开报工:自制工序任务开报工判断:工单+工序条码]
        #region[生产开报工:自制工序任务开报工判断:工单+工序条码,按序生产]
        /// <summary>
        /// æ‰«ç ä¿¡æ¯ä¸ºå·¥å•+工序条码
        /// </summary>
@@ -385,7 +385,7 @@
        }
        #endregion
        #region[生产开报工:外协工序任务开报工判断:工单号+工序]
        #region[生产开报工:外协工序任务开报工判断:工单号+工序,按序收发料]
        /// <summary>
        /// ç”Ÿäº§å¼€æŠ¥å·¥:外协工序任务开报工判断:工单号+工序
        /// </summary>
@@ -1046,5 +1046,456 @@
            return mes;
        }
        #endregion
        #region[生产开报工:自制工序任务开报工判断:工单+工序条码,不按序生产]
        /// <summary>
        /// æ‰«ç ä¿¡æ¯ä¸ºå·¥å•+工序条码
        /// </summary>
        /// <param name="ordercode">工单编号</param>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        public static ToMessage NoZZEncodingSeach(string ordercode, string stepcode)
        {
            var sql = "";
            string flwtype = ""; //工序属性
            string isbott = ""; //首道工序
            string isend = "";  //末道工序
            List<object> list = new List<object>();
            ScanStartReportData rt = new ScanStartReportData();
            var dynamicParams = new DynamicParameters();
            try
            {
                //判断当前工单是否关闭
                sql = @"select *   from TK_Wrk_Man where wo_code=@ordercode and status='CLOSED'";
                dynamicParams.Add("@ordercode", ordercode);
                var da0 = DapperHelper.selectdata(sql, dynamicParams);
                if (da0.Rows.Count > 0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "当前工单已关闭,不允许开报工操作!";
                    mes.data = null;
                    return mes;
                }
                //1.根据工单+工序查找当前工序是否首道工序
                sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.stepprice,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend,L.torg_code,L.torg_name
                        from TK_Wrk_Step A
                        left join  TStep T on A.step_code=T.stepcode
                        left join  TK_Wrk_Man M on A.wo_code=M.wo_code
                        left join  TMateriel_Info P on M.materiel_code=P.partcode
                        left join  TOrganization L on M.wkshp_code=L.torg_code
                        where A.wo_code=@ordercode and A.step_code=@stepcode";
                dynamicParams.Add("@ordercode", ordercode);
                dynamicParams.Add("@stepcode", stepcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    rt.wkshopcode = data.Rows[0]["torg_code"].ToString(); //车间编码
                    rt.wkshopname = data.Rows[0]["torg_name"].ToString(); //车间名称
                    rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号
                    rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码
                    rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称
                    rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //产品规格
                    rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //工序编码
                    rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //工序名称
                    rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //工序描述
                    rt.stepprice = data.Rows[0]["STEPPRICE"].ToString(); //工序工价
                    rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量
                    flwtype = data.Rows[0]["FLWTYPE"].ToString();//获取工序属性
                    isbott = data.Rows[0]["ISBOTT"].ToString();//首道工序
                    isend = data.Rows[0]["ISEND"].ToString();//末道工序
                    rt.seq = data.Rows[0]["SEQ"].ToString();//工序序号
                    //获取当前工序下道工序
                    sql = @"select A.isbott,A.isend,T.stepcode,T.stepname,A.stepprice from TK_Wrk_Step A
                            left join  TStep T on A.step_code=T.stepcode
                            where A.wo_code=@ordercode and A.seq=@seq+1 ";
                    dynamicParams.Add("@ordercode", ordercode);
                    dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
                    var dt = DapperHelper.selectdata(sql, dynamicParams);
                    if (dt.Rows.Count > 0) //有下道工序
                    {
                        rt.nextstepcode = dt.Rows[0]["STEPCODE"].ToString();//下道工序编码
                        rt.nextstepname = dt.Rows[0]["STEPNAME"].ToString();//下道工序名称
                        rt.nextstepprice = dt.Rows[0]["STEPPRICE"].ToString(); //下道工序工价
                    }
                    if (isend == "Y")  //当前工序是末道工序
                    {
                        rt.nextstepcode = "";//data.Rows[0]["STEPCODE"].ToString();//当前工序编码
                        rt.nextstepname = "";// data.Rows[0]["STEPNAME"].ToString();//当前工序名称
                        rt.nextstepprice = "";// data.Rows[0]["STEPPRICE"].ToString();//当前工序工价
                    }
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "当前工序任务不存在!";
                    mes.data = null;
                    return mes;
                }
                switch (flwtype)
                {
                    case "Z":  //自制工序
                        //首道工序时,判断是否有报工记录
                        sql = @"select *   from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
                        dynamicParams.Add("@ordercode", ordercode);
                        dynamicParams.Add("@stepcode", stepcode);
                        var data1 = DapperHelper.selectdata(sql, dynamicParams);
                        if (data1.Rows.Count > 0)
                        {
                            decimal good_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum();  //报工总数量
                            decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();  //不良数量
                            decimal laborbad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("LABORBAD_QTY")).Sum();  //工废数量
                            decimal materielbad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("MATERIELBAD_QTY")).Sum();  //料废数量
                                                                                                                                    //剩余可报工数量=任务数量-(报工数量+不良数量+工废废数量+料废数量)
                            decimal kbqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - (good_qty + ng_qty + laborbad_qty + materielbad_qty);
                            if (kbqty <= 0)//无可报工数量
                            {
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前工序无可报工数量!";
                                mes.data = null;
                                return mes;
                            }
                            else
                            {
                                rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量
                                rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - good_qty - ng_qty - laborbad_qty - materielbad_qty;  //未报数量=任务数量-已报数量-不良数量-工废数量-料废数量
                                rt.reportqty = good_qty + ng_qty + laborbad_qty + materielbad_qty;             //已报数量=报工数量+不良数量+工废数量+料废数量
                                mes.code = "200";
                                mes.count = 1;
                                mes.message = "查找成功!";
                                mes.data = rt;
                            }
                        }
                        else
                        {
                            rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量
                            rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //未报数量
                            rt.reportqty = 0;                                                    //已报数量
                            mes.code = "200";
                            mes.count = 1;
                            mes.message = "查找成功!";
                            mes.data = rt;
                        }
                        break;
                    case "W":  //外协工序
                        mes.code = "300";
                        mes.count = 0;
                        mes.message = "当前工单工序任务为外协,请前往外协操作标签页操作!";
                        mes.data = null;
                        break;
                    default:   //自制+外协工序
                        break;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
                return mes;
            }
            return mes;
        }
        #endregion
        #region[生产开报工:外协工序任务开报工判断:工单号+工序,按序收发料]
        /// <summary>
        /// æ‰«ç ä¿¡æ¯ä¸ºå·¥å•+工序条码
        /// </summary>
        /// <param name="ordercode">工单编号</param>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        public static ToMessage NoWXEncodingSeach(string SelectType, string ordercode, string stepcode)
        {
            var sql = "";
            string flwtype = ""; //工序属性
            string isbott = ""; //首道工序
            string isend = "";  //末道工序
            List<object> list = new List<object>();
            ScanStartReportDataOut rt = new ScanStartReportDataOut();
            var dynamicParams = new DynamicParameters();
            try
            {
                //判断当前工单是否关闭
                sql = @"select *   from TK_Wrk_Man where wo_code=@ordercode and status='CLOSED'";
                dynamicParams.Add("@ordercode", ordercode);
                var da0 = DapperHelper.selectdata(sql, dynamicParams);
                if (da0.Rows.Count > 0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "当前工单已关闭,不允许开报工操作!";
                    mes.data = null;
                    return mes;
                }
                //1.根据工单+工序查找当前工序是否首道工序
                sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.stepprice,A.status,A.plan_qty,A.isbott,A.isend,L.torg_code,L.torg_name
                        from TK_Wrk_Step A
                        left join  TStep T on A.step_code=T.stepcode
                        left join  TK_Wrk_Man M on A.wo_code=M.wo_code
                        left join  TMateriel_Info P on M.materiel_code=P.partcode
                        left join  TOrganization L on M.wkshp_code=L.torg_code
                        where A.wo_code=@ordercode and A.step_code=@stepcode";
                dynamicParams.Add("@ordercode", ordercode);
                dynamicParams.Add("@stepcode", stepcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    rt.wkshopcode = data.Rows[0]["torg_code"].ToString(); //车间编码
                    rt.wkshopname = data.Rows[0]["torg_name"].ToString(); //车间名称
                    rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号
                    rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码
                    rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称
                    rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //产品规格
                    rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //工序编码
                    rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //工序名称
                    rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //工序描述
                    rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量
                    rt.stepprice = data.Rows[0]["STEPPRICE"].ToString(); //工序工价
                    flwtype = data.Rows[0]["FLWTYPE"].ToString();//获取工序属性
                    isbott = data.Rows[0]["ISBOTT"].ToString();//首道工序
                    isend = data.Rows[0]["ISEND"].ToString();//末道工序
                    rt.seq = data.Rows[0]["SEQ"].ToString();//工序序号
                    //获取当前工序下道工序
                    sql = @"select A.isbott,A.isend,T.stepcode,T.stepname,A.stepprice from TK_Wrk_Step A
                            left join  TStep T on A.step_code=T.stepcode
                            where A.wo_code=@ordercode and A.seq=@seq+1 ";
                    dynamicParams.Add("@ordercode", ordercode);
                    dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
                    var dt = DapperHelper.selectdata(sql, dynamicParams);
                    if (dt.Rows.Count > 0) //有下道工序
                    {
                        rt.nextstepcode = dt.Rows[0]["STEPCODE"].ToString();//下道工序编码
                        rt.nextstepname = dt.Rows[0]["STEPNAME"].ToString();//下道工序名称
                        rt.nextstepprice = dt.Rows[0]["STEPPRICE"].ToString(); //下道工序工价
                    }
                    if (isend == "Y")  //当前工序是末道工序
                    {
                        rt.nextstepcode = "";// data.Rows[0]["STEPCODE"].ToString();//当前工序编码
                        rt.nextstepname = "";// data.Rows[0]["STEPNAME"].ToString();//当前工序名称
                        rt.nextstepprice = ""; //data.Rows[0]["NEXTSTEPPRICE"].ToString();//下道工序工价
                    }
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "当前扫码工序任务不存在!";
                    mes.data = null;
                    return mes;
                }
                switch (SelectType)
                {
                    case "OUT": //发料
                        switch (flwtype)
                        {
                            case "Z":
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前标签为自制标签,请前往自制操作标签页扫码!";
                                mes.data = null;
                                break;
                            case "W":
                                //1.判断是否有发料记录
                                sql = @"select *   from TK_Wrk_OutRecord R
                                            left join TCustomer C on R.wx_code=C.code
                                            where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'";
                                dynamicParams.Add("@ordercode", ordercode);
                                dynamicParams.Add("@stepcode", stepcode);
                                var data0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (data0.Rows.Count > 0)  //有发料记录
                                {
                                    decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();  //发料数量
                                    decimal ng_qty = data0.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// ä¸è‰¯æ•°é‡
                                    decimal laborbad_qty = data0.AsEnumerable().Select(d => d.Field<decimal>("LABORBAD_QTY")).Sum();  //工废数量
                                    decimal materielbad_qty = data0.AsEnumerable().Select(d => d.Field<decimal>("MATERIELBAD_QTY")).Sum();  //料废数量
                                    decimal kfqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - fqty - ng_qty - laborbad_qty - materielbad_qty; //剩余可发数量
                                    if (kfqty <= 0)
                                    {
                                        mes.code = "300";
                                        mes.count = 0;
                                        mes.message = "当前工序无可发料数量!";
                                        mes.data = null;
                                        return mes;
                                    }
                                    else
                                    {
                                        rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());     //任务数量
                                        rt.noreportqty = kfqty;                                              //未发数量=剩余可发数量
                                        rt.reportqty = fqty;                                                 //已发数量= å‘料数量
                                        rt.startqty = kfqty;                                                 //发料数量=剩余可发数量
                                        mes.code = "200";
                                        mes.count = 2;
                                        mes.message = "查询成功!";
                                        mes.data = rt;
                                    }
                                }
                                else
                                {
                                    rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());     //任务数量
                                    rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //未发数量=任务数量
                                    rt.reportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());   //已发数量=任务数量
                                    rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());    //发料数量=任务数量
                                    mes.code = "200";
                                    mes.count = 2;
                                    mes.message = "弹窗发料界面!";
                                    mes.data = rt;
                                }
                                break;
                            default:
                                break;
                        }
                        break;
                    case "IN": //收料
                        switch (flwtype)
                        {
                            case "Z"://自制
                                mes.code = "300";
                                mes.count = 0;
                                mes.message = "当前标签为自制标签,请前往自制操作标签页扫码!";
                                mes.data = null;
                                break;
                            case "W":
                                //1.判断是否有发料记录
                                sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
                                            isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.laborbad_qty),0) as laborbad_qty,isnull(sum(R.materielbad_qty),0) as materielbad_qty
                                            from TK_Wrk_OutRecord R
                                            left join TCustomer C on R.wx_code=C.code
                                            where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'
                                            group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
                                dynamicParams.Add("@ordercode", ordercode);
                                dynamicParams.Add("@stepcode", stepcode);
                                var data0 = DapperHelper.selectdata(sql, dynamicParams);
                                if (data0.Rows.Count > 0)  //有发料记录
                                {
                                    //1.判断是否有收料记录
                                    sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
                                                isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.laborbad_qty),0) as laborbad_qty,isnull(sum(R.materielbad_qty),0) as materielbad_qty
                                                from TK_Wrk_OutRecord R
                                                left join TCustomer C on R.wx_code=C.code
                                                where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'
                                                group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
                                    dynamicParams.Add("@ordercode", ordercode);
                                    dynamicParams.Add("@stepcode", stepcode);
                                    var data1 = DapperHelper.selectdata(sql, dynamicParams);
                                    if (data1.Rows.Count > 0) //有收料记录
                                    {
                                        decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//本道发料数量
                                        decimal sqty = data1.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//本道收料数量
                                        decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();//本道不良数量
                                        decimal laborbad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("LABORBAD_QTY")).Sum();  //本道工废数量
                                        decimal materielbad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("MATERIELBAD_QTY")).Sum();  //本道料废数量
                                                                                                                                                //剩余可发数量=本道发料数量-本道收料数量-本道不良数量-本道工废数量-本道料废数量
                                        decimal ksqty = fqty - sqty - ng_qty - laborbad_qty - materielbad_qty;
                                        if (ksqty <= 0)
                                        {
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.message = "当前工序:" + data.Rows[0]["STEPNAME"].ToString() + " æ— å¯æ”¶æ–™æ•°é‡!";
                                            mes.data = null;
                                            return mes;
                                        }
                                        else
                                        {
                                            rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());     //任务数量
                                            rt.noreportqty = ksqty;                                              //未收数量=本道发料数量
                                            rt.reportqty = sqty + ng_qty + laborbad_qty + materielbad_qty;          //已收数量
                                            rt.startqty = ksqty;                                                  //收料数量=本道发料数量
                                            data0.Merge(data1);//将指定的dt合并
                                            rt.list = data0.AsEnumerable().GroupBy(r => new
                                            {
                                                wo_code = r["wo_code"],
                                                step_code = r["step_code"],
                                                code = r["code"],
                                                name = r["name"]
                                            }).Select(g => new
                                            {
                                                Name = g.Key.code,
                                                tp = g.Key.name,
                                                fqty = g.Sum(i => (decimal)i["fqty"]),
                                                sqty = g.Sum(i => (decimal)i["sqty"]),
                                                ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
                                                laborbad_qty = g.Sum(i => (decimal)i["laborbad_qty"]),
                                                materielbad_qty = g.Sum(i => (decimal)i["materielbad_qty"])
                                            }).ToList();
                                            mes.code = "200";
                                            mes.count = 3;
                                            mes.message = "弹窗收料界面!";
                                            mes.data = rt;
                                        }
                                    }
                                    else
                                    {
                                        decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//本道发料数量
                                        rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString());     //任务数量
                                        rt.noreportqty = fqty;                                               //未收数量=本道发料数量
                                        rt.reportqty = 0;                                                    //已收数量
                                        rt.startqty = fqty;                                                  //收料数量=本道发料数量
                                                                                                             //
                                        data0.Merge(data1);//将指定的dt合并
                                        rt.list = data0.AsEnumerable().GroupBy(r => new
                                        {
                                            wo_code = r["wo_code"],
                                            step_code = r["step_code"],
                                            code = r["code"],
                                            name = r["name"]
                                        }).Select(g => new
                                        {
                                            Name = g.Key.code,
                                            tp = g.Key.name,
                                            fqty = g.Sum(i => (decimal)i["fqty"]),
                                            sqty = g.Sum(i => (decimal)i["sqty"]),
                                            ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
                                            laborbad_qty = g.Sum(i => (decimal)i["laborbad_qty"]),
                                            materielbad_qty = g.Sum(i => (decimal)i["materielbad_qty"])
                                        }).ToList();
                                        mes.code = "200";
                                        mes.count = 3;
                                        mes.message = "弹窗收料界面!";
                                        mes.data = rt;
                                    }
                                }
                                else
                                {
                                    mes.code = "300";
                                    mes.count = 0;
                                    mes.message = "当前工序:" + data.Rows[0]["STEPNAME"].ToString() + " æœªå‘æ–™,请先发料!";
                                    mes.data = null;
                                    return mes;
                                }
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.message = e.Message;
                mes.data = null;
                return mes;
            }
            return mes;
        }
        #endregion
    }
}
VueWebCoreApi/Tools/TOrganizationRecursion.cs
@@ -35,7 +35,7 @@
                          FOR XML PATH('')), 1, 1, '') AS torg_codelist";
                dynamicParams.Add("@torg_code", torg_code);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0&&data.Rows[0]["torg_codelist"].ToString()!=null)
                if (data.Rows.Count > 0&&data.Rows[0]["torg_codelist"].ToString()!=null&& data.Rows[0]["torg_codelist"].ToString()!="")
                {
                    mes.code = "200";
                    mes.count = 0;
@@ -46,7 +46,7 @@
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.message = "当前用户所属组织编码【" + torg_code + "】不存在!";
                    mes.message = "当前用户所属组织编码【" + torg_code + "】不存在或为空!";
                    mes.data = null;
                }
            }
VueWebCoreApi/VueWebCoreApi.csproj
@@ -55,6 +55,8 @@
        <Folder Include="wwwroot\DeviceRecordImage\image2\" />
        <Folder Include="wwwroot\newxls\" />
        <Folder Include="wwwroot\MouldRecordImage\" />
        <Folder Include="wwwroot\DeviceSopFile\" />
        <Folder Include="wwwroot\ProcessSopFile\" />
    </ItemGroup>
    <ItemGroup>