yl
2022-08-22 facb807b19e232c44852a91b6b442285eddfb0f5
VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -76,7 +76,7 @@
                }
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name,
                var sql = @"select A.id, A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name,
                            A.stck_code,D.name as stck_name,A.planstartdate,A.planenddate,U.username as createuser,A.createdate 
                            from TKimp_Ewo A
                            left join TMateriel_Info B on A.materiel_code=B.partcode
@@ -102,7 +102,7 @@
        #endregion
        #region[ERP订单下达]
        public static ToMessage MarkSaveErpOrder(string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username)
        public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username)
        {
            var sql = "";
            List<object> list = new List<object>();
@@ -181,26 +181,28 @@
                }
                if (decimal.Parse(erpqty) == decimal.Parse(markqty) + decimal.Parse(relse_qty))   //如果ERP订单=下单数量+已下单数量,则更新ERP订单表状态为CREATED:已创建
                {
                    sql = @"update  TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo";
                    sql = @"update  TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            wo = erpordercode,
                            erporderid = erporderid,
                            sumqty = sumqty
                        }
                    });
                }
                else   //更新ERP订单表状态为CREATING:创建中
                {
                    sql = @"update  TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo";
                    sql = @"update  TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            wo = erpordercode,
                            erporderid = erporderid,
                            sumqty = sumqty
                        }
                    });
@@ -233,7 +235,7 @@
        #endregion
        #region[ERP订单关闭]
        public static ToMessage ClosedErpOrder(string erpordercode, string username)
        public static ToMessage ClosedErpOrder(string erporderid,string erpordercode, string username)
        {
            var sql = "";
            List<object> list = new List<object>();
@@ -253,13 +255,14 @@
                else
                {
                    //关闭订单
                    sql = @"update  TKimp_Ewo set status='CLOSED' where wo=@wo";
                    sql = @"update  TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            wo = erpordercode
                            wo = erpordercode,
                            erporderid= erporderid
                        }
                    });
                }
@@ -729,8 +732,10 @@
            try
            {
                //获取工序任务信息
                sql = @"select A.wo_code,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty  from  TK_Wrk_Step A
                        left join TStep B on A.step_code=B.stepcode
                sql = @"select A.wo_code,P.partcode,P.partname,P.partspec,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty  from  TK_Wrk_Step A
                         left join TStep B on A.step_code=B.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
                        where A.wo_code=@wo_code";
                dynamicParams.Add("@wo_code", wo_code);
                var data = DapperHelper.selectdata(sql, dynamicParams);
@@ -1287,7 +1292,9 @@
                sql = @"update TK_Wrk_Step set status='START'  where wo_code=@mesordercode and step_code=@stepcode";
                list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
                //回写工单工序表状态为已开工
                sql = @"update TK_Wrk_Step set status='START'  where wo_code=@mesordercode and step_code=@stepcode";
                list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode} });
                //回写工单表状态为: 开工:START 
                sql = @"update TK_Wrk_Man set status='START'  where wo_code=@mesordercode";
                list.Add(new { str = sql, parm = new { mesordercode = mesordercode } });
@@ -1344,6 +1351,21 @@
                dynamicParams.Add("@wo_code", mesordercode);
                dynamicParams.Add("@step_code", stepcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                //获取开工记录的默认选中的设备(产线)与报工时的设备产线做对比判断
                sql = @"select A.eqp_code,B.name  from TK_Wrk_Record A
                        inner join TEqpInfo B on A.eqp_code=B.code
                        where A.wo_code=@wo_code and A.step_code=@step_code and A.style='S'";
                dynamicParams.Add("@wo_code", mesordercode);
                dynamicParams.Add("@step_code", stepcode);
                var da = DapperHelper.selectdata(sql, dynamicParams);
                if (da.Rows[0]["EQP_CODE"].ToString() != eqpcode)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "操作失败,当前报工产线应为:"+ da.Rows[0]["NAME"].ToString() + "!";
                    mes.data = null;
                    return mes;
                }
                if (data.Rows.Count > 0)
                {
                    //修改报工记录
@@ -1373,7 +1395,7 @@
                else
                {
                    //获取主表最大ID
                    sql = @"select IDENT_CURRENT('TK_Wrk_Record')+1 as id";
                    sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
                    var dt = DapperHelper.selecttable(sql);
                    //写入开报工记录表
                    sql = @"insert into  TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date) 
@@ -1467,7 +1489,7 @@
                else
                {
                    //获取主表最大ID
                    sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id";
                    sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
                    var dt = DapperHelper.selecttable(sql);
                    //写入外协记录主表
                    sql = @"insert into  TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,fqty,lm_user,lm_date) 
@@ -1538,6 +1560,21 @@
                dynamicParams.Add("@step_code", stepcode);
                dynamicParams.Add("@wx_code", wxcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                //获取发料记录的默认选中的外协供应商与收料时的外协供应商做对比判断
                sql = @"select A.wx_code,B.name   from TK_Wrk_OutRecord A
                        inner join TCustomer B on A.wx_code=B.code
                        where A.wo_code=@wo_code and A.step_code=@step_code and A.style='F' ";
                dynamicParams.Add("@wo_code", mesordercode);
                dynamicParams.Add("@step_code", stepcode);
                var da = DapperHelper.selectdata(sql, dynamicParams);
                if (da.Rows[0]["WX_CODE"].ToString() != wxcode)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "操作失败,当前收料外协供方应为:" + da.Rows[0]["NAME"].ToString() + "!";
                    mes.data = null;
                    return mes;
                }
                if (data.Rows.Count > 0)
                {
                    //修改外协记录主表
@@ -1564,7 +1601,7 @@
                else
                {
                    //获取主表最大ID
                    sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id";
                    sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
                    var dt = DapperHelper.selecttable(sql);
                    //写入外协记录主表
                    sql = @"insert into  TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date) 
@@ -1748,7 +1785,7 @@
        #endregion
        #region[生产开报工,工序检验提交保存]
        public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkuser, string checktypecode, string checkresult, string checkdescr, string username, List<StepCheck> json)
        public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, string checktypecode, string checkresult, string checkdescr, string username, List<StepCheck> json)
        {
            var sql = "";
            string[] arra = new string[] { };
@@ -1762,16 +1799,16 @@
                list.Clear();
                //写入工序检验记录主表
                sql = @"insert into  TStepCheckRecord(wo_code,part_code,step_code,checkstaned_code,check_user,check_type,check_result,check_descr,lm_user,lm_date)
                                values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkuser,@checktypecode,@checkresult,@checkdescr,@lm_user,@lm_date)";
                list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkuser = checkuser, checktypecode = checktypecode, checkresult = checkresult, checkdescr = checkdescr, lm_user = username, lm_date = date } });
                sql = @"insert into  TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_result,check_descr,lm_user,lm_date)
                                values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checkresult,@checkdescr,@lm_user,@lm_date)";
                list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, checktypecode = checktypecode, checkresult = checkresult, checkdescr = checkdescr, lm_user = username, lm_date = date } });
                //写入工序检验记录子表
                //获取主表最大ID
                sql = @"select IDENT_CURRENT('TStepCheckRecord')+1 as id";
                sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id";
                var dt = DapperHelper.selecttable(sql);
                for (int i = 0; i < json.Count; i++)
                {
                    sql = @"insert into  TStepCheckRecordSub(m_id,checkiem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date)
                    sql = @"insert into  TStepCheckRecordSub(m_id,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date)
                                values(@m_id,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_result,@lm_user,@lm_date)";
                    list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), checkiem_seq = int.Parse(json[i].seq), checkitem_code = json[i].code, checkitem_name = json[i].name, checkitem_descr = json[i].descr, check_result = json[i].checkresult, lm_user = username, lm_date = date } });