yl
2022-07-13 c63b40452aeaf1b46ef716da9f5dc9e8c2a843a6
VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -54,12 +54,12 @@
                if (paydatestartdate != "" && paydatestartdate != null)
                {
                    search += "and A.paydate between @paydatestartdate and @paydateenddate ";
                    dynamicParams.Add("@paydatestartdate", paydatestartdate);
                    dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00");
                    dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59");
                }
                if (createstartdate != "" && createstartdate != null)
                {
                    search += "and A.createdate between @paydatestartdate and @paydateenddate ";
                    search += "and A.createdate between @createstartdate and @createenddate ";
                    dynamicParams.Add("@createstartdate", createstartdate);
                    dynamicParams.Add("@createenddate", createenddate + " 23:59:59");
                }
@@ -494,7 +494,7 @@
                            from TFlw_Rtdt A
                            left join TStep B on A.step_code=B.stepcode
                            left join TFlw_Rout C on A.rout_code=C.code
                            where A.first_choke='Y' and A.rout_code=@routecode
                            where A.rout_code=@routecode
                            and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
                    list.Add(new
                    {
@@ -554,7 +554,7 @@
                            from TFlw_Rtdt A
                            left join TStep B on A.step_code=B.stepcode
                            left join TFlw_Rout C on A.rout_code=C.code
                            where A.first_choke='Y' and A.rout_code='R001'
                            where  A.rout_code=@routecode
                            and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
                    list.Add(new
                    {
@@ -567,6 +567,7 @@
                            planenddate = planenddate,
                            status = "ALLO",  //派发
                            username = username,
                            routecode= routecode,
                            CreateDate = DateTime.Now.ToString()
                        }
                    });
@@ -612,22 +613,25 @@
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    //查询生产订单表数据
                    sql = @"select *  from TKimp_Ewo where wo=@m_po";
                    dynamicParams.Add("@m_po", m_po);
                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
                    decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//以下单数量
                    if ((relse_qty - decimal.Parse(orderqty)) == 0)  //全部撤销 订单状态回写未开始,已下单数量为0
                    if (m_po != "" && m_po != null)
                    {
                        //回写订单表状态及已下单数量
                        sql = @"update TKimp_Ewo set status='NEW',relse_qty=0  where wo=@m_po";
                        list.Add(new { str = sql, parm = new { m_po = m_po } });
                    }
                    else
                    {
                        //回写订单表状态及已下单数量
                        sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty  where wo=@m_po";
                        list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } });
                        //查询生产订单表数据
                        sql = @"select *  from TKimp_Ewo where wo=@m_po";
                        dynamicParams.Add("@m_po", m_po);
                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
                        decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//以下单数量
                        if ((relse_qty - decimal.Parse(orderqty)) == 0)  //全部撤销 订单状态回写未开始,已下单数量为0
                        {
                            //回写订单表状态及已下单数量
                            sql = @"update TKimp_Ewo set status='NEW',relse_qty=0  where wo=@m_po";
                            list.Add(new { str = sql, parm = new { m_po = m_po } });
                        }
                        else
                        {
                            //回写订单表状态及已下单数量
                            sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty  where wo=@m_po";
                            list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } });
                        }
                    }
                    //删除工单工序表
                    sql = @"delete TK_Wrk_Step  where wo_code=@wocode";
@@ -759,6 +763,11 @@
                    if (arra.Length == 1) //工单号二维码
                    {
                        ordercode = arra[0]; //获取指定字符串前面的字符
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "请扫描工序二维码!";
                        mes.data = null;
                        return mes;
                    }
                    if (arra.Length == 2) //工单号+工序号二维码
                    {
@@ -766,12 +775,12 @@
                        stepcode = arra[1]; //获取指定字符串前面的字符
                    }
                    if (ordercode != "" && ordercode == null) //工单号不为空,工序号为空
                    if (ordercode != "" && ordercode != null) //工单号不为空,工序号为空
                    {
                        search += "and A.wo_code=@ordercode ";
                        dynamicParams.Add("@ordercode", ordercode);
                    }
                    if (ordercode != "" && ordercode != "") //工单号不为空,工序号不为空
                    if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空
                    {
                        search += "and A.wo_code=@ordercode ";
                        dynamicParams.Add("@ordercode", ordercode);
@@ -779,18 +788,18 @@
                        dynamicParams.Add("@stepcode", stepcode);
                    }
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "二维码信息为空!";
                    mes.data = null;
                    return mes;
                }
                //else
                //{
                //    mes.code = "300";
                //    mes.count = 0;
                //    mes.Message = "二维码信息为空!";
                //    mes.data = null;
                //    return mes;
                //}
                if (stepcode != "")
                {
                    //查找当前工序属性
                    sql = @"select *  from TStep where TStep where stepcode=@stepcode";
                    sql = @"select *  from TStep  where stepcode=@stepcode";
                    dynamicParams.Add("@stepcode", stepcode);
                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
                    if (data0.Rows.Count > 0) 
@@ -859,18 +868,23 @@
                    if (arra.Length == 1) //工单号二维码
                    {
                        ordercode = arra[0]; //获取指定字符串前面的字符
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "请扫描工序二维码!";
                        mes.data = null;
                        return mes;
                    }
                    if (arra.Length == 2) //工单号+工序号二维码
                    {
                        ordercode = arra[0]; //获取指定字符串前面的字符
                        stepcode = arra[1]; //获取指定字符串前面的字符
                    }
                    if (ordercode != "" && ordercode == null) //工单号不为空,工序号为空
                    if (ordercode != "" && ordercode != null) //工单号不为空,工序号为空
                    {
                        search += "and A.wo_code=@ordercode ";
                        dynamicParams.Add("@ordercode", ordercode);
                    }
                    if (ordercode != "" && ordercode != "") //工单号不为空,工序号不为空
                    if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空
                    {
                        search += "and A.wo_code=@ordercode ";
                        dynamicParams.Add("@ordercode", ordercode);
@@ -878,18 +892,18 @@
                        dynamicParams.Add("@stepcode", stepcode);
                    }
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "二维码信息为空!";
                    mes.data = null;
                    return mes;
                }
                //else
                //{
                //    mes.code = "300";
                //    mes.count = 0;
                //    mes.Message = "二维码信息为空!";
                //    mes.data = null;
                //    return mes;
                //}
                if (stepcode != "")
                {
                    //查找当前工序属性
                    sql = @"select *  from TStep where TStep where stepcode=@stepcode";
                    sql = @"select *  from TStep  where stepcode=@stepcode";
                    dynamicParams.Add("@stepcode", stepcode);
                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
                    if (data0.Rows.Count > 0)
@@ -959,7 +973,7 @@
                    {
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "二维码信息错误,请扫描工序任务卡或者报工打印标签!";
                        mes.Message = "请扫描工序条码!";
                        mes.data = null;
                        return mes;
                    }
@@ -1084,9 +1098,92 @@
            try
            {
                //班组获取人员列表
                sql = @"select usercode,username  from TUser where usergroup_code=@stepcode";
                sql = @"select usercode,username  from TUser where usergroup_code=@usergroupcode and is_delete<>'1'";
                dynamicParams.Add("@usergroupcode", usergroupcode);
                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 MesOrderSelectUser(string usercode)
        {
            string sql = "";
            string search = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                if (usercode != "" && usercode != null) //工单号不为空,工序号为空
                {
                    search += "and usercode=@usercode ";
                    dynamicParams.Add("@usercode", usercode);
                }
                //班组获取人员列表
                sql = @"select usercode,username  from TUser where is_delete<>'1' "+search;
                dynamicParams.Add("@usercode", usercode);
                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 MesOrderStepSelectWX(string orderstepqrcode)
        {
            string sql = "";
            string ordercode = "";
            string stepcode = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                if (orderstepqrcode != "" && orderstepqrcode != null)
                {
                    string[] arra = orderstepqrcode.Split(';');
                    if (arra.Length == 1) //工单号二维码
                    {
                        ordercode = arra[0]; //获取指定字符串前面的字符
                    }
                    if (arra.Length == 2) //工单号+工序号二维码
                    {
                        ordercode = arra[0]; //获取指定字符串前面的字符
                        stepcode = arra[1]; //获取指定字符串前面的字符
                    }
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "二维码信息为空!";
                    mes.data = null;
                    return mes;
                }
                //获取外协下拉框
                sql = @"select C.code,C.name from TFlw_Rteqp A
                        left join TCustomer C on A.eqp_code=C.code
                        where A.step_code=@stepcode and A.style='W'";
                dynamicParams.Add("@stepcode", stepcode);
                var data = DapperHelper.selectdata(sql,dynamicParams);
                mes.code = "200";
                mes.Message = "查询成功!";
                mes.data = data;
@@ -1346,7 +1443,7 @@
                string date = DateTime.Now.ToString(); //获取系统时间
                list.Clear();
                //判断是否有发料记录(有(同工单+工序+外协供方修改) 无:新增)
                sql = @"select *  from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wxcode and style='F'";
                sql = @"select *  from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='F'";
                dynamicParams.Add("@wo_code", mesordercode);
                dynamicParams.Add("@step_code", stepcode);
                dynamicParams.Add("@wx_code", wxcode);
@@ -1358,7 +1455,7 @@
                             where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
                    list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, fqty = decimal.Parse(fqty), username = username, CreateDate = date } });
                    //写入子表
                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date)
                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date)
                                values(@m_id,@wx_code,@out_person,@out_time,@fqty,@lm_user,@lm_date)";
                    list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
                }
@@ -1373,7 +1470,7 @@
                    list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'F', fqty = fqty, lm_user = username, lm_date = date } });
                    //写入子表
                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date)
                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date)
                                values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)";
                    list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
                }
@@ -1443,7 +1540,7 @@
                             where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
                    list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } });
                    //写入外协记录子表
                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date)
                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date)
                                values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@lm_user,@lm_date)";
                    list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } });
@@ -1470,7 +1567,7 @@
                    list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } });
                    //写入外协记录子表
                    sql = @"insert into  TK_Wrk_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
                    sql = @"insert into  TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
                                values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
                    list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });