|
@@ -0,0 +1,197 @@
|
|
|
+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.LJException;
|
|
|
+using JLHHJSvr.Tools;
|
|
|
+using LJLib.DAL.SQL;
|
|
|
+using LJLib.Net.SPI.Server;
|
|
|
+
|
|
|
+namespace JLHHJSvr.Excutor
|
|
|
+{
|
|
|
+ internal sealed class SaveMattressAuditingExcutor : ExcutorBase<SaveMattressAuditingRequest, SaveMattressAuditingResponse>
|
|
|
+ {
|
|
|
+ protected override void ExcuteInternal(SaveMattressAuditingRequest request, object state, SaveMattressAuditingResponse rslt)
|
|
|
+ {
|
|
|
+ var tokendata = BllHelper.GetToken(request.token);
|
|
|
+ if (tokendata == null)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "会话已经中断,请重新登录";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ using (var con = new SqlConnection(GlobalVar.ConnectionString))
|
|
|
+ using (var cmd = con.CreateCommand())
|
|
|
+ {
|
|
|
+ con.Open();
|
|
|
+
|
|
|
+ // 初始化属性
|
|
|
+ //AutoInit.AutoInitS(cmd, request.mattress);
|
|
|
+
|
|
|
+ using (cmd.Transaction = con.BeginTransaction())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ if (request.xd_flag != null)
|
|
|
+ {
|
|
|
+ // 业务下单/取消
|
|
|
+
|
|
|
+ var power94 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 94);
|
|
|
+ if (!power94 && request.xd_flag == 1)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("你没有业务下单权限");
|
|
|
+ }
|
|
|
+
|
|
|
+ var power95 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 95);
|
|
|
+ if (!power95 && request.xd_flag == 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("你没有取消业务下单权限");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var updateField = "xd_flag, xd_auditingrep, xd_auditingdate";
|
|
|
+
|
|
|
+ foreach (int itemid in request.mattressids)
|
|
|
+ {
|
|
|
+ var mattressInfo = new u_mattress() { mattressid = itemid };
|
|
|
+ if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag, xd_flag") != 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "查找报价单据失败:" + itemid;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (request.xd_flag == 1)
|
|
|
+ {
|
|
|
+ if (mattressInfo.flag == 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "床垫已审核,不能业务下单!(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mattressInfo.xd_flag == 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "床垫已完成业务下单(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mattressInfo.xd_flag = 1;
|
|
|
+ mattressInfo.xd_auditingrep = tokendata.username;
|
|
|
+ mattressInfo.xd_auditingdate = DateTime.Now;
|
|
|
+
|
|
|
+
|
|
|
+ if (DbSqlHelper.Update(cmd, "u_mattress", null, mattressInfo, "mattressid", updateField) <= 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("因网络或其它原因,【业务下单/取消】操作失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (mattressInfo.js1_flag == 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "已产品补充审核,不能取消下单!(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mattressInfo.xd_flag == 0)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "未进行业务下单,不能取消下单!(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mattressInfo.xd_flag = 0;
|
|
|
+ mattressInfo.xd_auditingrep = "";
|
|
|
+ mattressInfo.xd_auditingdate = null;
|
|
|
+
|
|
|
+ if (DbSqlHelper.Update(cmd, "u_mattress", null, mattressInfo, "mattressid", updateField) <= 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("因网络或其它原因,【业务下单/取消】操作失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (request.flag != null)
|
|
|
+ {
|
|
|
+ // 审核
|
|
|
+
|
|
|
+ var power73 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 73);
|
|
|
+ if (!power73 && request.flag == 1)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("你没有审核权限");
|
|
|
+ }
|
|
|
+
|
|
|
+ var power74 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 74);
|
|
|
+ if (!power74 && request.flag == 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("你没有取消审核权限");
|
|
|
+ }
|
|
|
+
|
|
|
+ var updateField = "flag, auditingrep, auditingdate";
|
|
|
+
|
|
|
+ foreach (int itemid in request.mattressids)
|
|
|
+ {
|
|
|
+ var mattressInfo = new u_mattress() { mattressid = itemid };
|
|
|
+ if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag") != 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "查找报价单据失败:" + itemid;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (request.flag == 1)
|
|
|
+ {
|
|
|
+ if (mattressInfo.flag == 1)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "床报价已完成审核(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mattressInfo.flag = 1;
|
|
|
+ mattressInfo.auditingrep = tokendata.username;
|
|
|
+ mattressInfo.auditingdate = DateTime.Now;
|
|
|
+
|
|
|
+ if (DbSqlHelper.Update(cmd, "u_mattress", null, mattressInfo, "mattressid", updateField) <= 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("因网络或其它原因,【审核消】操作失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (mattressInfo.flag == 0)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "床报价已完成撤销审核!(" + itemid + ")";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mattressInfo.flag = 0;
|
|
|
+ mattressInfo.auditingrep = "";
|
|
|
+ mattressInfo.auditingdate = null;
|
|
|
+
|
|
|
+ if (DbSqlHelper.Update(cmd, "u_mattress", null, mattressInfo, "mattressid", updateField) <= 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("因网络或其它原因,【撤销审核】操作失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ cmd.Transaction.Commit();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ cmd.Transaction.Rollback();
|
|
|
+ rslt.ErrMsg = e.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|