Commit ef7952c6 authored by solho's avatar solho

新增結算,運營辦相關

parent 993a79fa
......@@ -349,9 +349,11 @@ namespace WebAPI.Controllers
case "CF":
IsConfirm = 1; return_msg = "確認完成"; break;
case "RV":
IsConfirm = 0; return_msg = "已撤回"; break;
IsConfirm = 0; return_msg = ""; break;
case "RJ":
IsConfirm = 0; return_msg = "已退回"; break;
case "RJOp":
IsConfirm = 0; return_msg = "已退至運營辦"; break;
default:
IsConfirm = 0; return_msg = "已退回"; break;
}
......@@ -394,10 +396,11 @@ namespace WebAPI.Controllers
#endregion
//Confirm_Class.Add("PG"); Confirm_Class.Add("Leader"); //test
#region 取得FLOW相關
cmd.CommandText = @"select et.*,etf.id AS Flowid,etf.*,
cmd.CommandText = @"select et.*,etf.id AS Flowid,etf.*,eeas.cn_name as ascn_name,
etfs.* FROM esn_todos et
left join esn_todos_Flow etf on et.sn=etf.esn_todos_sn
left join esn_todos_Flow_StepType etfs on etfs.id=etf.StepType_id
left join evw_Employee eeas on eeas.user_id=et.AssignedTo
where et.sn in(@Esn_Todos_Sn)
";
......@@ -415,13 +418,14 @@ namespace WebAPI.Controllers
#endregion
String Wade_User_ID = obj_input["Wade_User_ID"].ToString(), Reject_Description = obj_input["Reject_Description"].ToString(),
date0 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Tsql = "";
date0 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Tsql = "",RJOp="";
JToken JtSn;
//List<String> sql = new List<string>();
int StepType_id_Previous, StepType_id, StepType_idHis;
foreach (DataRow dr in ds.Tables[0].Rows)
{
RJOp = "";
StepType_id_Previous = dr["StepType_id_Previous"] == DBNull.Value ? 0 : Convert.ToInt32(dr["StepType_id_Previous"]);
//StepType_id_next = Convert.ToInt32(dr["StepType_id_next"]);
StepType_id = dr["StepType_id"] == DBNull.Value ? 0 : Convert.ToInt32(dr["StepType_id"]);
......@@ -438,7 +442,7 @@ namespace WebAPI.Controllers
+ @"_IsConfirm],StepType_id_Previous,Description,[create_user_id],[Create_time],update_user_id,update_time) "
+ " OUTPUT Inserted.id into @TempTable "
+ " values (" + dr["sn"] + ",'" + CStepTypeNext.id + "'," + IsConfirm + ",'" + 1
+ "','" + Reject_Description + "','" + Wade_User_ID + "'" + ",'" + date0 + "'" + ",'" + Wade_User_ID + "'" + ",'" + date0 + "'" + "); "
+ "',@Reject_Description,@Wade_User_ID,'" + date0 + "'" + ",@Wade_User_ID,'" + date0 + "'" + "); "
;
}
else //update
......@@ -482,22 +486,33 @@ namespace WebAPI.Controllers
CStepTypeCur.id = CStepTypeNext.id; //回復與下一步 同ID
Tsql = Tsql + CStepTypeNext.Map_Class + "_IsConfirm =" + IsConfirm + ",";
}
else if (Confirm_Method == "RJOp")
{
Tsql = Tsql + "PG_IsConfirm =" + IsConfirm + "," + "PE_IsConfirm =" + IsConfirm + "," + "Leader_IsConfirm =" + IsConfirm + ","; //退回後,改為更新所有Flow狀態確認
CStepTypeNext = AllStepType.Where(p => p.Step_Value == Step_Value_previous).FirstOrDefault();
StepType_idHis = CStepTypeCur.id;
RJOp= @"update esn_Todos set AssignStatus = 'AS01', AssignStatus_name = '運營辦指派' where sn = " + dr["sn"] + @";
insert into esn_OthData(oth_ID, FldName, FldValue, FldMemo, FldMemo2, oth_Status, updateUser, update_time)
select " + dr["sn"] + ",'SuggestPoints'," + dr["Points"] + ",@Reject_Description,'','I',@ascn_name,GETDATE()";
cmd.Parameters.AddWithValue("@ascn_name", dr["ascn_name"]);
}
else
{
Tsql = Tsql + CStepTypeCur.Map_Class + "_IsConfirm =" + IsConfirm + ",";
StepType_idHis = CStepTypeCur.id;
}
Tsql = Tsql + " StepType_id = '" + CStepTypeNext.id + "',StepType_id_Previous = '" + CStepTypeCur.id +
"',Description = '" + Reject_Description + "',update_user_id='" + Wade_User_ID + "',update_time='" + date0 + "' "
"',Description = @Reject_Description,update_user_id=@Wade_User_ID,update_time='" + date0 + "' "
+ " output Inserted.id into @TempTable where id =" + dr["Flowid"] + ";"
;
}
Tsql = Tsql + "select @FlowId=id from @TempTable;";
Tsql = Tsql + "insert into esn_todos_Flow_his (Flow_id,ConfirmTime,FromType_id,ToType_id,ConfirmUserId,ConfirmUserClass,ConfirmMethod,Description,Create_User_id,Create_time) "
+ " values (@FlowId,'" + date0 + "','" + StepType_idHis + "','" + CStepTypeNext.id + "','" + Wade_User_ID
+ "','" + CStepTypeCur.Map_Class + "','" + Confirm_Method + "','" + Reject_Description + "','" + Wade_User_ID + "','" + date0 + "'" + ") ;";
Tsql += @"select @FlowId=id from @TempTable;
insert into esn_todos_Flow_his (Flow_id,ConfirmTime,FromType_id,ToType_id,ConfirmUserId,ConfirmUserClass,ConfirmMethod,Description,Create_User_id,Create_time) "
+ " values (@FlowId,'" + date0 + "','" + StepType_idHis + "','" + CStepTypeNext.id + "',@Wade_User_ID,'" + CStepTypeCur.Map_Class + "','" + Confirm_Method + "',@Reject_Description,@Wade_User_ID,'" + date0 + "'" + ") ;";
Tsql += RJOp;
cmd.Parameters.AddWithValue("@Reject_Description", Reject_Description);
cmd.Parameters.AddWithValue("@Wade_User_ID", Wade_User_ID);
}
cmd.CommandText = @"declare @TempTable TABLE(id INT)
......
using ExcelDataReader;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
using System.Web.Http.Cors;
using WebAPI.Models;
using WebAPI.Tool;
using static WebAPI.Models.Esn_Todos;
using static WebAPI.Tool.Common;
namespace WebAPI.Controllers
{
[RoutePrefix("Esn_Subitem")]
......@@ -24,9 +16,13 @@ namespace WebAPI.Controllers
{
HttpResponseMessage result;
CommonResponseMsg response;
public Esn_todosController()
{
String connString;
public Esn_todosController()
{
result = new HttpResponseMessage(HttpStatusCode.OK);
response = new CommonResponseMsg();
connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
}
/// <summary>
/// 取得歷史明細
......@@ -41,81 +37,81 @@ namespace WebAPI.Controllers
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
String connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
JObject obj_input = JObject.Parse(input.ToString());
try
{
using (SqlConnection Conn = new SqlConnection(connString))
{
String sqlstr = "";
int SN = 853141;
sqlstr = @"select distinct td.SN, case_id, finishedDate as finish_date, attorneyDueDate as int_due_date,
LegalDueDate as legal_due_date, todosStatus_name as todos_status_name, taskDescription as taskName, assignedTo_userID,
AssignStatus_name,Points as point_num,
Case When pointsType='POINT' Then '點數' When pointsType='AMT' Then '金額' When ISNULL(PointsType,'')='MP' Then '加乘點數' Else '點數' END as point_type
, '' as point_note, proc_id, matter_name
,case when (ISNULL(points,0)<>0 AND ISNULL(PointsType,'') <>'MP') AND ISNULL(exchangeRate,0)=0 THEn 1 ELSE ISNULL(exchangeRate,0) END as exchangeRate
from esn_Todos td where td.SN in (" + SN + ")";
sqlstr = "select distinct td.*, tds.date_points_settlement, tds.date_points_settlement_pic_confirm from (" + sqlstr + ") td left join esn_todos_points tds on tds.sn=td.sn ";
//'---+ 承辦人員
sqlstr = "select t11.*, isnull(ui1.cn_name, '&nbsp;') as cn_name from (" + sqlstr + ") t11 left join s_user_info ui1 on ui1.user_id=t11.assignedTo_userID";
//'gDebugha_wade(sqlstr)
//'//+ caseNo
sqlstr = @"select distinct t1.*, ci1.country_id, ci1.case_volume, ci1.case_name, apply_type_zh_tw, business_type_zh_tw,
c1.customer_name,etf.id as Flow_id,etf.StepType_id,etf.PE_IsConfirm,etf.PG_IsConfirm,etf.Leader_IsConfirm,etf.Description,etf.StepType_id_Previous,
etfs.Map_Class,etfs.id as Map_Class_StepType_id,etf.Is_Settlement from (" + sqlstr + @") t1
left join p_case_info ci1 on t1.case_id=ci1.case_id
left join i_apply_type at1 on at1.case_type_id=ci1.case_type_id AND ci1.apply_type_id=at1.apply_type_id
left join i_business_type bt1 on bt1.case_type_id=ci1.case_type_id AND ci1.business_type_id=bt1.business_type_id
left join c_customer c1 on c1.customer_id=ci1.customer_id";
//'結算 FLOW'
sqlstr += @"
left join esn_todos_Flow etf on etf.esn_todos_sn = t1.sn
left join esn_todos_Flow_his etfh on etf.id=etfh.Flow_id
left join esn_todos_Flow_StepType etfs on etf.StepType_id=etfs.id ";
//'gDebugha_wade(sqlstr)
//' wade todos
sqlstr = "select t3.*, isnull(cp3.ctrl_proc_zh_tw,('[IPS:' + matter_name + ']')) as TaskL1Name from (" + sqlstr + @")
t3 left join p_proc_info pc3 on pc3.proc_id=t3.proc_id
left join i_ctrl_proc cp3 on pc3.ctrl_proc_id=cp3.ctrl_proc_id";
//sqlstr0 = sqlstr
// sqlstr = " SELECT SN as attr_SN, 'caseNo' as class_1, case_id as attr_case_id, case_volume as attr_caseNo, case_volume as 案件編號, " & _
// " ('<span class=Office_Name>' + country_id + '<span><br/><span class=caseNo2>' + '' + '</span>') as '國家<br/>案件編號2', "
// sqlstr = sqlstr & " 'tdTitle' as class_1, ('<span class=title>' + case_name + '</span><br/><span class=Client_CompanyName>' + customer_name + '<span>') as '案件名稱<br/>客戶名稱', "
// sqlstr = sqlstr & " 'LL' as class_applyType, apply_type_zh_tw as '申請類型',"
//sqlstr = sqlstr & " 'LL' as class_todo, ('<span class=MatterName>' + TaskL1Name +'<span><br/><span class=TaskDescription>' + taskName + '</span>') as '上層事項<br/>子層事項', "
//sqlstr = sqlstr & " 'LL' as class_status, ('<div class=ToDosStatus_Name>' + todos_status_name + '</div><div class=Status_Name>' + '' + '</div>') as '事項狀態<br>案件狀態', "
// sqlstr = sqlstr & " assignedTo_userID as attr_userID, ('<span class=AssignedTo_Name>' + cn_name + '<span>') as 承辦人員, "
//sqlstr = sqlstr & " ('<span class=legalDueDate>' + convert(varchar, legal_due_date, 23) + '<span>') as '法定到期日', "
//sqlstr = sqlstr & " finish_date as 完成日, int_due_date as 事務所到期日, 'tdr' as class_1, point_num as 點數,point_type as 點數類型, 'LL' as class_assignStatus, AssignStatus_name as '指派狀態', 'tdr' as class_1, exchangeRate as 評分, 'date_points_settlement' as class_2, date_points_settlement as 點數結算日, Flow_id as attr_Flowid,isnull(Map_Class,'PG') as attr_MapClass ,StepType_id_Previous as attr_StepTypeidPrevious ,Is_Settlement as attr_IsSettlement,isnull(StepType_id,'1') as 目前結算流程, 'checkbox2' as attr_type,'Field_PG' AS class_c1, (case when PG_IsConfirm =1 then 1 else null end) as 程序已確認, 'checkbox2' as attr_type ,'Field_PE' AS class_c2 ,(case when PE_IsConfirm =1 then 1 else null end) as 承辦人已確認, 'checkbox2' as attr_type ,'Field_Leader' AS class_c3, (case when Leader_IsConfirm =1 then 1 else null end) as 主管已確認,Description as 退回原因, date_points_settlement_pic_confirm as attr_title, 'checkbox2' as attr_type, 'date_points_settlement_pic_confirm' as class_3 /* , case when date_points_settlement_pic_confirm is null then null else 1 end as 確認結算, point_note as 備註 */ "
// sqlstr = sqlstr & " from (" & sqlstr0 & ") tt "
//'gDebugha_wade(sqlstr)
;
SqlCommand cmd = new SqlCommand("", Conn)
{
CommandText = @";with didata as (
SELECT badge, CASE WHEN b.text_zh_tw IN ('台北','台中' ,'高雄' ) THEN 'TW' ELSE 'CN' END AS dico
FROM ehr_employee a
LEFT JOIN ehr_dictionary b ON a.EmpCustom1 = b.value AND b.dictionary_name = 'eCD_EmpCustom1' AND b.is_enabled = 1
),todosData as(
SELECT DISTINCT td.*, tds.date_points_settlement, tds.date_points_settlement_pic_confirm
FROM (
SELECT DISTINCT td.SN, case_id, finishedDate AS finish_date, CustDueDate, LegalDueDate AS legal_due_date, todosStatus_name AS todos_status_name, taskDescription AS taskName, assignedTo_userID, AssignStatus_name, Points, proc_id, matter_name
FROM esn_Todos td
WHERE td.SN IN (@SN)
) td
LEFT JOIN esn_todos_points tds ON tds.sn = td.sn
),Otherjoin as(
SELECT DISTINCT t11.*, ci1.country_id, ci1.case_volume, ci1.case_name, fui.cn_name AS fcn_name, CASE
WHEN isnull(fui.main_email, '') = '' THEN fui.email ELSE fui.main_email
END AS fmain_email, ci1.flow_user_id, apply_type_zh_tw, business_type_zh_tw, c1.customer_name, etf.id AS Flow_id, etf.StepType_id, etf.PE_IsConfirm,
etf.PG_IsConfirm, etf.Leader_IsConfirm, etf.Description, etf.StepType_id_Previous, etfs.Map_Class, etfs.id AS Map_Class_StepType_id,
etf.Is_Settlement, etfs.Step_Value, etf.update_user_id, etab.points_tobe, au.main_email, au.director_email, au.director_name,
isnull(au.cn_name, ' ') AS cn_name, eqeau.Emp_DSContury AS auco, eqefui.Emp_DSContury AS fuico
--,(select dico from CTE1 where badge=au.director_badge ) as dico
,isnull(cp3.ctrl_proc_zh_tw,('[IPS:' + matter_name + ']')) as TaskL1Name
, dico
FROM todosData t11
LEFT JOIN evw_p_case_info ci1 ON t11.case_id = ci1.case_id
LEFT JOIN c_customer c1 ON c1.customer_id = ci1.customer_id
LEFT JOIN esn_todos_Flow etf ON etf.esn_todos_sn = t11.sn
LEFT JOIN esn_todos_Flow_his etfh ON etf.id = etfh.Flow_id
LEFT JOIN esn_todos_Flow_StepType etfs ON etf.StepType_id = etfs.id
LEFT JOIN esn_Todos_auto_points etab ON etab.sn = t11.sn
LEFT JOIN evw_Employee fui ON fui.user_id = ci1.flow_user_id
LEFT JOIN evw_Employee au ON t11.AssignedTo_userid = au.user_id
LEFT JOIN didata di ON au.director_badge = di.badge
LEFT JOIN evw_qResult_EmpDS eqefui ON eqefui.Emp_DSNum = fui.Emp_DSNum
LEFT JOIN evw_qResult_EmpDS eqeau ON eqeau.Emp_DSNum = au.Emp_DSNum
LEFT JOIN p_proc_info pc3 ON pc3.proc_id = t11.proc_id
LEFT JOIN i_ctrl_proc cp3 ON pc3.ctrl_proc_id = cp3.ctrl_proc_id
)
SELECT SN AS attr_SN, 'caseNo' AS class_1, case_id AS attr_case_id, case_volume AS attr_caseNo, case_volume AS 案件編號, ('' + country_id + '') AS '國家', 'tdTitle' AS class_1
, ('' + case_name + '/' + customer_name + '' ) AS '案件名稱/客戶名稱', 'LL' AS class_applyType, apply_type_zh_tw AS '申請類型', 'LL' AS class_todo
, ('' + TaskL1Name + '/' + taskName + '') AS '處理事項/子事項', 'LL' AS class_status, todos_status_name AS '子事項狀態', director_email AS attr_directoremail,
cast(director_name AS NVARCHAR(100)) AS attr_directorname, main_email AS attr_mainemail, assignedTo_userID AS attr_userID, auco AS attr_auco,
dico AS attr_dico, ('' + cast(cn_name AS NVARCHAR(100)) + '') AS 承辦人員, flow_user_id AS attr_flowuserid, fmain_email AS attr_fmainemail, fuico AS attr_fuico,
cast(fcn_name AS NVARCHAR(100)) AS 流程人員, ('' + convert(VARCHAR, legal_due_date, 23) + '') AS '官方期限', finish_date AS 完成日, CustDueDate AS 客戶期限,
'tdr' AS class_1, Points AS 系統派點, 'LL' AS class_assignStatus, AssignStatus_name AS '指派狀態', 'tdr' AS class_1, 'date_points_settlement' AS class_2,
date_points_settlement AS 點數確認日, Flow_id AS attr_Flowid, isnull(Map_Class, 'NF') AS attr_MapClass, StepType_id_Previous AS attr_StepTypeidPrevious,
Is_Settlement AS attr_IsSettlement, update_user_id AS attr_updateuserid, isnull(Step_Value, '0') AS 目前審核流程
, 'checkbox2' AS attr_type, 'Field_PG' AS class_c1, (CASE WHEN PG_IsConfirm = 1 THEN 1 ELSE NULL END ) AS 程序已確認
, 'checkbox2' AS attr_type, 'Field_PE' AS class_c2, (CASE WHEN PE_IsConfirm = 1 THEN 1 ELSE NULL END ) AS 承辦人已確認
, 'checkbox2' AS attr_type, 'Field_Leader' AS class_c3, (CASE WHEN Leader_IsConfirm = 1 THEN 1 ELSE NULL END ) AS 主管已確認
, Description AS 退回原因
From Otherjoin
"
};
cmd.Parameters.AddWithValue("@SN", obj_input["SN"].ToString());
DataTable dt = SqlToDt(cmd);
response.Code = "1";
response.Msg = "匯出完畢";
response.Code = "1";
//response.Msg = Hislist;
string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(dt);
response.Msg = JSONString;
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
}
}
catch (Exception e)
{
response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
}
......@@ -128,6 +124,88 @@ namespace WebAPI.Controllers
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
}
[Route("UpdateDatePointsSettlement")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage Update_date_points_settlement(ParamModel param)
{
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
JObject obj_input = JObject.Parse(input.ToString());
try
{
using (SqlConnection Conn = new SqlConnection(connString))
{
String sns = obj_input["SN"].ToString();
String sqlstr = @"select td.SN, tdp.SN as SN_tdp,td.points,AssignedTo_userid FROM esn_todos td
left join esn_todos_points tdp on tdp.sn=td.sn
WHERE td.sn in ("+ sns +")";
String value = obj_input["value"].ToString();
value = value == "" ? "null" : obj_input["value"].ToString();
SqlCommand cmd = new SqlCommand("",Conn)
{
CommandText = sqlstr
};
cmd.Parameters.AddWithValue("@SN", obj_input["SN"].ToString());
DataTable dt = SqlToDt(cmd);
String point, AssignedTo_userID ;
DataRow dr;
sqlstr = "declare @TempTable TABLE(id INT) declare @FlowId int; ";
cmd.Parameters.Clear();
for (int i = 0;i< dt.Rows.Count;i++ )
{
dr = dt.Rows[i];
point = dr["points"].ToString();
AssignedTo_userID = dr["AssignedTo_userID"].ToString();
if (dr["SN_tdp"] == DBNull.Value)
{
sqlstr += string.Format(@"insert into esn_todos_points(sn,date_points_settlement,date_points_settlement_AssignTo,date_points_settlement_Point,update_user_id,update_time)
values (@SN{0},@value,@AssignedTo_userID{0},@points{0},@gWadeID,getdate()); ", i);
}
else
{
sqlstr += string.Format(@"update esn_todos_points set date_points_settlement=@value,date_points_settlement_AssignTo=@AssignedTo_userID{0}
,date_points_settlement_Point=@points{0} ,update_user_id=@gWadeID,Update_time=GETDATE() where SN =@SN{0};", i);
}
cmd.Parameters.AddWithValue(string.Format("@SN{0}",i), dr["SN"].ToString());
cmd.Parameters.AddWithValue(string.Format("@AssignedTo_userID{0}", i), AssignedTo_userID);
cmd.Parameters.AddWithValue(string.Format("@points{0}", i), point);
sqlstr += string.Format(@"update esn_todos_Flow Set Is_Settlement = 1,update_user_id = @gWadeID,Update_time = GETDATE()
,StepType_id =(select id from esn_todos_Flow_StepType a where a.Map_Class='HR') output INSERTED.id INTO @TempTable where esn_todos_sn =@SN{0};
select @FlowId=id from @TempTable;
insert into esn_todos_Flow_his(Flow_id,ConfirmTime,FromType_id,ToType_id,ConfirmUserId,ConfirmUserClass,ConfirmMethod,Description,Create_User_id,Create_time)
select id as Flow_id,@value,a.StepType_id,StepType_id,@gWadeID,'HR','SL','確認日期:' + @value,@gWadeID,GETDATE() from esn_todos_Flow a where a.id=@FlowId;
", i);
}
cmd.Parameters.AddWithValue("@value", value);
cmd.Parameters.AddWithValue("@gWadeID", obj_input["gWadeID"].ToString());
cmd.CommandText = sqlstr;
dt = SqlToDt(cmd);
response.Code = "1";
string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(dt);
response.Msg = "確認完畢";
}
}
catch (Exception e)
{
response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
}
}
else
{
response.Code = "0";
response.Msg = "no input or format error";
}
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment