using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Text; using JLHHJSvr.BLL; using JLHHJSvr.Com; using JLHHJSvr.Com.Model; using JLHHJSvr.Helper; using JLHHJSvr.LJException; using JLHHJSvr.Tools; using LJLib.DAL.SQL; using LJLib.Net.SPI.Server; namespace JLHHJSvr.Excutor { internal sealed class ReCalculateNoAuditExcutor : ExcutorBase { protected override void ExcuteInternal(ReCalculateNoAuditRequest request, object state, ReCalculateNoAuditResponse rslt) { var tokendata = BllHelper.GetToken(request.token); if (tokendata == null) { rslt.ErrMsg = "会话已经中断,请重新登录"; return; } if (request.list == null) { rslt.ErrMsg = "提交缺少列表参数,请检查!"; return; } if (!request.list.Any()) { rslt.ErrMsg = "至少提交一条需要重算的记录"; return; } using (var con = new SqlConnection(GlobalVar.ConnectionString)) using (var cmd = con.CreateCommand()) { con.Open(); var helper = HelperBase.GetHelper(cmd, new HelperBase.Context() { tokendata = tokendata }); foreach (var mattress in request.list) { DbSqlHelper.SelectOne(cmd, mattress, "flag,deptid"); if (mattress.flag == 1) throw new LJCommonException("存在报价单已审核,不能重算!"); if (mattress.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!"); var dept = new u_dept() { deptid = mattress.deptid.Value }; DbSqlHelper.SelectOne(cmd, dept, "pricelistid"); if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!"); } using (cmd.Transaction = con.BeginTransaction()) { try { foreach(var mattress in request.list) { var mattress_temp = helper.GetMattress(mattress.mattressid); var mxList = helper.GetMattressMxMtrl(mattress.mattressid); helper.CalCulateFormula(mattress_temp, mxList); helper.SaveMattress(mattress_temp, mxList); } cmd.Transaction.Commit(); } catch (Exception e) { cmd.Transaction.Rollback(); rslt.ErrMsg = e.Message; } } } } } }