/// <summary> /// 待判线材客户需求调配 /// </summary> /// <param name="list">日志</param> /// <returns></returns> public bool InsertRoll_Proc4(List <Mod_TMC_ROLL_DEPLOY_LOG> list) { ArrayList arraySql = new ArrayList(); for (int i = 0; i < list.Count; i++) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TMC_ROLL_DEPLOY_LOG(C_BATCH_NO,C_MAT_CODE,C_STL_GRD,C_SPEC,C_OLDAREA,C_NEWAREA,C_EMPID,C_EMPNAME,C_ROLL_PROCID,C_QUA,C_PACK,C_JUDGE_LEV,C_STD_CODE,C_REMARK,C_OLDCUST,C_NEWCUST,C_OLDCON,C_NEWCON)values("); strSql.Append("'" + list[i].C_BATCH_NO + "',"); strSql.Append("'" + list[i].C_MAT_CODE + "',"); strSql.Append("'" + list[i].C_STL_GRD + "',"); strSql.Append("'" + list[i].C_SPEC + "',"); strSql.Append("'" + list[i].C_OLDAREA + "',"); strSql.Append("'" + list[i].C_NEWAREA + "',"); strSql.Append("'" + list[i].C_EMPID + "',"); strSql.Append("'" + list[i].C_EMPNAME + "',"); strSql.Append("'" + list[i].C_ROLL_PROCID + "',"); strSql.Append("'1',"); strSql.Append("'" + list[i].C_PACK + "',"); strSql.Append("'" + list[i].C_JUDGE_LEV + "',"); strSql.Append("'" + list[i].C_STD_CODE + "',"); strSql.Append("'单卷调配',"); strSql.Append("'" + list[i].C_OLDCUST + "',"); strSql.Append("'" + list[i].C_NEWCUST + "',"); strSql.Append("'" + list[i].C_OLDCON + "',"); strSql.Append("'" + list[i].C_NEWCON + "'"); strSql.Append(")"); arraySql.Add(strSql.ToString()); StringBuilder strSql2 = new StringBuilder(); string str = $@"SELECT MAX(TT.C_ORDER_NO) C_ORDER_NO FROM (SELECT T.C_ORDER_NO, T.N_LINE_MATCH_WGT, T.N_WGT, (NVL(T.N_WGT, 0) - NVL(T.N_LINE_MATCH_WGT, 0)) MAXWGT, T.C_MAT_CODE, T.C_STL_GRD FROM TMO_ORDER T WHERE T.C_CON_NO = '{list[i].C_NEWCON}' AND T.C_MAT_CODE = '{list[i].C_MAT_CODE}' AND T.C_PACK='{list[i].C_PACK}' and t.C_STD_CODE='{list[i].C_STD_CODE}' ) TT ORDER BY TT.MAXWGT DESC"; DataTable dt = DbHelperOra.Query(str).Tables[0]; #region //排产订单分配量减量 string str2 = $@"SELECT T.C_ORDER_NO, T.N_WGT FROM TRC_ROLL_PRODCUT T WHERE T.C_ID = '{list[i].C_ROLL_PROCID}'"; DataTable dt2 = DbHelperOra.Query(str2).Tables[0]; string oldorder = dt2.Rows[0]["C_ORDER_NO"].ToString(); string rollwgt = dt2.Rows[0]["N_WGT"].ToString(); string updatejian = $@"update tmo_order t set t.n_line_match_wgt=nvl(t.n_line_match_wgt,0)-{rollwgt} where t.C_ORDER_NO='{oldorder}'"; arraySql.Add(updatejian); #endregion if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["C_ORDER_NO"].ToString())) { string neworder = dt.Rows[0]["C_ORDER_NO"].ToString(); string updateadd = $@"update tmo_order t set t.n_line_match_wgt=nvl(t.n_line_match_wgt,0)+{rollwgt} where t.C_ORDER_NO='{neworder}'"; arraySql.Add(updateadd); strSql2.Append("update trc_roll_prodcut t set t.C_SALE_AREA='" + list[i].C_NEWAREA + "',t.C_CUST_NAME='" + list[i].C_NEWCUST + "',t.C_CKDH='" + list[i].C_OLDAREA + "',t.C_CKRY='" + list[i].C_OLDCUST + "',T.C_CON_NO='" + list[i].C_NEWCON + "',T.C_ORDER_NO='" + neworder + "' where t.C_ID='" + list[i].C_ROLL_PROCID + "' and t.c_batch_no='" + list[i].C_BATCH_NO + "' and t.c_move_type='E'"); arraySql.Add(strSql2.ToString()); } else { strSql2.Append("update trc_roll_prodcut t set t.C_SALE_AREA='" + list[i].C_NEWAREA + "',t.C_CUST_NAME='" + list[i].C_NEWCUST + "',t.C_CKDH='" + list[i].C_OLDAREA + "',t.C_CKRY='" + list[i].C_OLDCUST + "',T.C_CON_NO='" + list[i].C_NEWCON + "',T.C_ORDER_NO=NULL where t.C_ID='" + list[i].C_ROLL_PROCID + "' and t.c_batch_no='" + list[i].C_BATCH_NO + "' and t.c_move_type='E'"); arraySql.Add(strSql2.ToString()); } } return(DbHelperOra.ExecuteSqlTran(arraySql)); }