| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using JLHHJSvr.BLL;
- using JLHHJSvr.Com;
- using JLHHJSvr.Com.Model;
- using JLHHJSvr.Helper;
- using JLHHJSvr.LJException;
- using LJLib.DAL.SQL;
- using LJLib.Net.SPI.Server;
- using LJLib.SQLEX;
- using static JLHHJSvr.Helper.CacheHelper;
- namespace JLHHJSvr.Excutor
- {
- internal sealed class ReCalculateNoAuditExcutor : ExcutorBase<ReCalculateNoAuditRequest, ReCalculateNoAuditResponse>
- {
- 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 = GlobalVar.ConnectionString.NewSqlConnection())
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- var helper = HelperBase.GetHelper<MattressHelper>(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 = helper.Cache.GetData<u_dept,DeptMapping>(mattress.deptid.Value);
- if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
- }
- using (cmd.Transaction = con.BeginTransaction())
- {
- try
- {
- foreach (var mattress in request.list)
- {
- helper.RecalculateOne(mattress);
- }
- cmd.Transaction.Commit();
- }
- catch (Exception e)
- {
- cmd.Transaction.Rollback();
- rslt.ErrMsg = e.Message;
- }
- }
- }
- }
- }
- }
|