yl
2022-10-09 e7b01bc7ec4cfb3d978f01fbe2bf1a6461fd639b
VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -2871,64 +2871,91 @@
                                for (int n = 0; n < dt3.Rows.Count; n++)
                                {
                                    string sql4 = @"select  A.wo_code,A.eqp_code,A.Time_Start,A.time_end, 
                                                 (case  B.Status when 'SCHED' then '已排程' when 'ALLOC' then '已派发' when 'START' then '已开工' end ) status
                                                  from TK_Wrk_EqpAps  A
                                                  left join mes_tk_wrk_man B on A.wo_code=B.Wo_Code
                                                  left join gn_eqp_eqpinfo C on A.eqp_code=C.code
                                                  where TO_char(time_start,'YYYY-MM-DD')='" + list4[m].name + "' and A.eqp_code='" + dt3.Rows[n]["CODE"] + "' and B.isaps='Y' and B.status IN('SCHED','ALLOC','START')";
                                    DataTable dt4 = DBHelper.GetTable(sql4);
                                                     (case  B.Status when 'SCHED' then '已排程' when 'ALLOC' then '已派发' when 'START' then '已开工' end ) status
                                                      from TK_Wrk_EqpAps  A
                                                      left join TK_Wrk_Man B on A.wo_code=B.wo_code
                                                      left join TEqpInfo C on A.eqp_code=C.code
                                                      where CONVERT(varchar(100), time_start, 23)=@time_start and A.eqp_code=@eqp_code and B.isaps='Y' and B.status IN('SCHED','ALLOC','START')";
                                    dynamicParams.Add("@time_start", list4[m].name);
                                    dynamicParams.Add("@eqp_code", dt3.Rows[n]["CODE"]);
                                    var dt4 = DapperHelper.selectdata(sql4, dynamicParams);
                                    if (dt4.Rows.Count > 0)
                                    {
                                        for (int g = 0; g < dt4.Rows.Count; g++)
                                        {
                                            json = new DWZJson()
                                            {
                                                statusCode = "300",
                                                message = "修改失败!,日期:" + dt4.Rows[g]["TIME_START"] + "有【" + dt4.Rows[g]["STATUS"] + "】工单:" + dt4.Rows[g]["WO_CODE"] + "",
                                            };
                                            return json;
                                            mes.code = "300";
                                            mes.count = 0;
                                            mes.Message = "修改失败!,日期:" + dt4.Rows[g]["TIME_START"] + "有【" + dt4.Rows[g]["STATUS"] + "】工单:" + dt4.Rows[g]["WO_CODE"] + "";
                                            mes.data = null;
                                            return mes;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    list.Add(@"update gn_wkm_capac_plan set wkshift_code='" + CapSetupCode + "',classtype='" + CaptPlanType + "', enable='Y',lm_user='" + lm_user + "',lm_time=sysdate  where id='" + CaptPlanId + "'");
                    list.Add(@"delete gn_wkm_capac_plan_sub where m_id='" + CaptPlanId + "'");
                    //更新排产生产资源主表
                    sql = @"update gn_wkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_time=@lm_time  where id=@id";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            id=captplanid,
                            wkshift_code = capsetupcode,
                            classtype = captplantype,
                            lm_user =username,
                            lm_time= DateTime.Now.ToString()
                        }
                    });
                    //删除排产生产资源子表
                    sql = @"delete TWkm_capac_plan_sub  where m_id=@id";
                    list.Add(new
                    {
                        str = sql,
                        parm = new
                        {
                            id = captplanid
                        }
                    });
                    //循环写入排产生产资源子表
                    for (int i = 0; i < objs.Count; i++)
                    {
                        list.Add(@"insert into gn_wkm_capac_plan_sub(m_id, id, wkdate,wkshift_code)
                                     values('" + CaptPlanId + "',gn_wkm_capac_plan_sub_S.nextVal,to_date('" + objs[i].name + "','yyyy-MM-dd'),'" + objs[i].key + "')");
                    }
                    int count = DBHelper.Executesqltran(list, pt.ToArray());
                    if (count > 0)
                    {
                        json = new DWZJson()
                        sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values()";
                        list.Add(new
                        {
                            statusCode = "200",
                            message = "修改成功!",
                        };
                            str = sql,
                            parm = new
                            {
                                m_id = captplanid,
                                wkdate = objs[i].name,
                                wkshift_code= objs[i].key
                            }
                        });
                    }
                    bool aa = DapperHelper.DoTransaction(list);
                    if (aa)
                    {
                        mes.code = "200";
                        mes.count = 0;
                        mes.Message = "操作成功!";
                        mes.data = null;
                    }
                    else
                    {
                        json = new DWZJson()
                        {
                            statusCode = "300",
                            message = "修改失败!",
                        };
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "操作失败!";
                        mes.data = null;
                    }
                }
            }
            catch (Exception e)
            {
                json = new DWZJson()
                {
                    statusCode = "300",
                    message = e.Message,
                };
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }